PHP: array_pop() function
PHP: Pop the element off the end of array
The array_pop() function is used to remove the last element of an array. For an empty array, the function returns NULL.
Note: This function will reset() the array pointer of the input array after use.
Version:
(PHP 4 and above)
Syntax:
array_pop(array_name)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
array_pop | The specified array whose last element will be removed. | Required | Array |
Return value:
The last value of array_pop.
Value Type: Mixed*.
*Mixed: Mixed indicates multiple (but not necessarily all) types.
Example:
<?php
$array1= array('Mathematics','Physics','Chemistry','Biology');
$subject=array_pop($array1);
print_r($array1);
?>
Output:
Array ( [0] => Mathematics [1] => Physics [2] => Chemistry )
Pictorial Presentation:
View the example in the browser
Practice here online :
See also
Previous: array_pad
Next: array_push
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/php/function-reference/array_pop.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics