Seeing Array_slice () is a function that reminds me of the range value clause in VFP.
This function has a total of four parameters:
Array to be evaluated (required)
Starting position of the value (required)
The terminating position of the value, if not filled in by default to the last element of the array (optional)
Whether to retain the original key name (optional)
This function can be used as a paging operation
1. When the value range is positive (starting from the first element in the array, take two elements)
<?Php$arr= Array ('a','b','C','D'); $ret= Array_slice ($arr,1,2);p Rint_r ($ret);//Run resultArray ([0] =b [1] =c)
2. When the value starting range is negative, the number of values is positive
When the starting position of the value is negative, it is counted from the end of the element, and then the value
<? PHP $arr Array (' A ', ' B ', ' C ', ' d ', ' e '); $ret Array_slice ($arr, -2,2); Print_r ($ret); // Run result Array ( [0] = + d [1] = e)
3. Do you want to leave the original key name here? No example is done.
This article for fennel dumplings Blog original, welcome reprint, reproduced please indicate the source
Fennel Dumplings Blog http://www.cnblogs.com/hxjz/
Deep parsing of PHP array functions array_slice