Home >Backend Development >PHP Problem >How to intercept the first few of php array
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);" .
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!