PHP array_pop() Function

Example

Remove the last element from the array

<?php
$a=array("red","green","blue");
array_pop($a);
print_r($a);
?>

Run Example

Definition and Usage

The array_pop() function removes the last element from the array.

Syntax

array_pop(array)
Parameter Description
array Required. Specifies an array.

Technical Details

Return Value: Returns the last value of the array. If the array is empty or not an array, NULL is returned.
PHP Version: 4+