PHP array_pop() work: Here, we will find out about the array_pop() work with the example in PHP.
PHP array_pop() work
array_pop() work is utilized to erase/pop last component from the cluster.
Syntax:
array_pop(array);
Here, the cluster is the information exhibit, capacity will erase the last component from it.
Example:
Input:
//initial array is
$arr = array(100, 200, 300, 10, 20, 500);
//deleting elements
array_pop($arr);
array_pop($arr);
array_pop($arr);
Output:
Array
(
[0] => 100
[1] => 200
[2] => 300
)
PHP code to erase components from a cluster utilizing array_pop() work
<?php
$arr = array(100, 200, 300, 10, 20, 500);
array_pop($arr);
array_pop($arr);
array_pop($arr);
print("array after removing elements...\n");
print_r($arr);
?>
Output
array after removing elements...
Array
(
[0] => 100
[1] => 200
[2] => 300
)