You 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.

Example:

$planets = array("Mercury", "Venus", "Earth", "Mars");

// Removing last array item
$planets_new = array_pop($planets);