We used to show you how to add elements to the tail of an array. Let's show you how to delete an array element at the end of an array. First, the function that we need to use is PHP function Array_pop ().
- The function array_pop () removes some elements from the end of the array:
- ?
- /* First we create an array */
- $ Fruitarray = Array ("Apple", "orange", "banana", "Peach", "pear");
- /* Remove an element from the end of the array using the Array_pop () function */
- $ popped = Array_pop ($fruitArray);
- /* Now we'll show the key (key) and value of all the elements in the deleted array on the Web page */
- while (list ($key, $value) = each ($fruitArray)) {
- echo "$key: $value
";
- }
- echo "
Finally, the value of the element that was just deleted is stored in the $popped variable, and its value is: $popped";
- ? >
The results appear as follows:
0:apple
1:orange
2:banana
3:peach
Finally, the value of the element deleted by the PHP function Array_pop () is stored in the $popped variable, and its value is: Pear.
http://www.bkjia.com/PHPjc/446376.html www.bkjia.com true http://www.bkjia.com/PHPjc/446376.html techarticle we used to show you how to add elements to the tail of an array. Let's show you how to delete an array element at the end of an array. First of all, we ...
-