How To Remove Last Element of Array in PHP - array_pop() Function
PHP Array FunctionsYou can use the array_pop() function to remove an element or value from the end of an array. The array_pop() function returns the last value of array. If the array is empty (or the variable is not an array), then the returned value is NULL.
This function pops the element off the end of array.
Example:
$planets = array("Mercury", "Venus", "Earth", "Mars");
// Removing last array item
$planet = array_pop($planets);