Php Last Array Element Delete Function

What is array_pop Function?

Explanation

The "array_pop" function is used to delete the last element of an array.

Syntax:


array_pop(array)

In the above syntax "array" specifies the array from which the last element is to be deleted.

Example :


<?php
$b=array("c"=>"Cherry","b"=>"Strawberry", "d"=>"Berry");
$pop = array_pop($b);
print_r($b);
?>
Result :

Array ( [c] => Cherry [b] => Strawberry )

In the above example the last element of the array "Berry" is deleted.

PHP Topics


Ask Questions

Ask Question