To put it simply, the array_splice () function removes the array elements starting from a certain position in the given array and returns an array containing the removed units. Therefore, your negligence is: simply put, the array_splice () function removes the array elements starting from a certain position in the given array, returns an array containing the removed cells. Therefore, your negligence lies in:
Foreach (array_splice ($ array, 2) as $ key => $ value)
In this code, the result of array_splice ($ array, 2) is the elements that are removed from the array, rather than the data you want to retain.
You need to take a closer look at the prototype declaration of array_splice:
Array array_splice (array & $ input, int $ offset .....)
Note: The & $ input parameter is transmitted by address instead of the normal value. Therefore, after calling the array_splice function, the data in the $ input array is directly modified.
In summary, the modified code is as follows:
$ Value) {echo "$ key: $ value
";}?>
The above is the solution of php array_splice function. For more information, see PHP Chinese website (www.php1.cn )!