Removing the Last Element of an Array in PHP
To remove the last
element of an array, the array_pop function is used.
See the example:
<?php
$arr = [1, 2, 3, 4, 5];
array_pop($arr);
var_dump($arr);
?>
Code execution result:
[1, 2, 3, 4]
To remove the last
element of an array, the array_pop function is used.
See the example:
<?php
$arr = [1, 2, 3, 4, 5];
array_pop($arr);
var_dump($arr);
?>
Code execution result:
[1, 2, 3, 4]