The array_pop() function deletes the last element of an array. It returns the value of the last element of the array. If the array is empty, NULL is returned.
Syntax
array_pop(arr)
Parameters
- arr − The specified array
Return
The array_pop() function returns the last element of the array. If the array is empty, NULL is returned.
The following is an example −
Example
<?php
$arr = array("laptop", "mobile", "tablet");
$res = array_pop($arr);
print_r($res);
?>Output
The following is the output −
tablet