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 Unit of the Array (Pops)

Syntax

array_pop($array);

Definition and Usage

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

Parameter

Serial NumberParameters and Description
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 Usage Example 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