Home >Backend Development >PHP Problem >How to get the first few data from php array
array_slice() function removes a segment of value from 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 tutorial: "PHP Tutorial"
The above is the detailed content of How to get the first few data from php array. For more information, please follow other related articles on the PHP Chinese website!