Jump to: navigation, search

Php array pop

From w3cyberlearnings

Contents

PHP function array_pop

This function returns the last element of the array, and deletes the last element of the original array.

Syntax array_pop

  • array: array input
array_pop(array);

Example 1

  • Get the last array value.
<?php

$person = array(
	 'Sailor Lee',
	 'John Edward',
	 'Thomas Christie',
	 'Brinkley',
	 'Jack Paris');

$first_person = array_pop($person);

echo $first_person;
?>


Output

Jack Paris

Example 2

<?php

$person = array(
	 'Sailor Lee',
	 'John Edward',
	 'Thomas Christie',
	 'Brinkley',
	 'Jack Paris');

array_pop($person);

print_r($person);
?>

Output


Array
(
    [0] => Sailor Lee
    [1] => John Edward
    [2] => Thomas Christie
    [3] => Brinkley
)



Relate

Related Links


Navigation
Web
SQL
MISC
References