Deletion method: 1. Use array_pop() to delete the last element, the syntax is "array_pop($arr);"; 2. Use array_splice() to delete the last N elements, just set the second parameter Just "-N", the syntax is "array_splice($arr,-N)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php deletes the array at the end Several methods of elements
Method 1: Use array_pop() function to delete the last element
array_pop($array)
Function deletes the last element in the array.
This function will change the original array; the return value is the last value of the array. If the array is empty or not an array, NULL will be returned.
Method 2: Use the array_splice() function to delete the last few array elements
array_splice() function is used to delete the array part of the elements; set the second parameter of the array_splice() function to-N
to delete the lastN
array elements.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to delete the last element of an array in php. For more information, please follow other related articles on the PHP Chinese website!