English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP array_pop() function usage and example

PHP Array Function Manual

PHP array_pop() function pops the last element of the array (pop)

Syntax

array_pop($array);

Definition and usage

This function pops and returns the last element of the array and reduces the length of the array.1.

Parameter

Serial numberParameters and descriptions
1

array(Required)

It specifies an array.

Return value

It returns the last value of the array, reducing the array by one element. If the array is empty (if it is not an array), it will return NULL.

Online example

array_pop() function pops the last element, with example usage and output result

<?php
   $input = array("a"=>"banana","b"=>"apple","c"=>"orange");
   
   print_r(array_pop($input));
   print_r("\n");
   print_r(array_pop($input));
?>
Test and see‹/›

Output result:

orange
apple

PHP Array Function Manual