How to remove last element of an array in PHP
How to remove last element of an array in PHP, We can remove last element of an array using array_pop function in php. First we are using an array with sample values, then we are assigning it to an $array variable, before applying the function we are printing array with print_r function surrounded with pre tags, this pre tag will display an array in human readable manner. After that we are using array_pop by simply passing the array, after applying the function we are again printing the array surrounded with pre tags.
$array = array(‘hi’, ‘this’, ‘is’, ‘an’, ‘array’);
remove last 2 elements from array php