The array_pop function removes the last element of the array.
What is the syntax of the array_pop function in PHP?
array_pop(array)
Parameter | Description |
---|---|
array | Array to remove the last element from – Required |
Example of array_pop function
<?php
$arr=array("green","blue","red");
array_pop($arr);
print_r($arr);
?>
In the above example, we removed the last element of the array using the array_pop function.