Home >Backend Development >PHP Problem >How to intercept the first few of php array

How to intercept the first few of php array

藏色散人
藏色散人Original
2021-03-18 09:22:495101browse

How to intercept the first few data of php array: first create a PHP sample file; then define an array; finally intercept the first few data of the array through "array_slice($arr,0,4);" .

How to intercept the first few of php array

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

php function array_slice is used ( Get the first and last digits of the array)

array_slice() function takes out a segment of value in the array based on conditions and returns it.

Syntax: array_slice(array,start,length,preserve)

Get the first 4 digits of the array

array_slice($arr,0,4);

Get the last 4 digits of the array

array_slice($arr,-4,4);

or

array_slice($arr,-4);

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to intercept the first few of php array. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn