Home >Backend Development >PHP Tutorial >PHP deletes the last element and first element of an array_PHP tutorial
Just use the array_pop function in php4, function prototype:
mixed array_pop(array array)
For example:
$array = array(php,jsp,asp);
$count = count($array);
echo old:
;
for($i=0;$i<$count;$i++) echo $array[$i].
;
array_pop($array);
$count = count($array);
echo new:
;
for($i=0;$i<$count;$i++) echo $array[$i].
;
?>
Output result:
old:
php
jsp
asp
new:
php
jsp
php delete the first element of array
$new_data = array_splice($insert_data, 1); //Delete the first value of the array
Author "Rock 21's Blog"