• PHP Video Tutorials

PHP - Function array_pop()



Syntax

array_pop ( $array );

Definition and Usage

This function pops and returns the last value of the array, shortening the array by one element.

Parameters

Sr.No Parameter & Description
1

array(Required)

It specifies an array.

Return Values

It returns the last value of the array, shortening the array by one element.

Example

Try out following example −

<?php
   $input = array("a"=>"banana","b"=>"apple","c"=>"orange");
   
   print_r(array_pop($input));
   print_r("\n");
   print_r(array_pop($input));
?> 

This will produce the following result −

orange
apple
php_function_reference.htm
Advertisements