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
- Delete the first item in the array uses array_shift.
Related Links
- array_change_key_case
- array_chunk
- array_combine
- array_count_values
- array_diff_assoc
- array_diff_key
- array_diff_uassoc
- array_diff_ukey
- array_diff
- array_fill_keys
- array_fill
- array_filter
- array_flip
- array_intersect_assoc
- array_intersect_key
- array_intersect_uassoc
- array_intersect_ukey
- array_intersect
- array_key_ exists
- array_keys