Analysis of the specific usage of the PHP function array_pop () _ PHP Tutorial

Source: Internet
Author: User
Analyze the usage of the PHP function array_pop. We have introduced how to add elements at the beginning and end of an array. Next we will introduce how to delete array elements at the end of an array. First, we have introduced how to add elements at the beginning and end of an array. Next we will introduce how to delete array elements at the end of an array. First, we need to use the PHP function array_pop ().

  • The array_pop () function deletes some elements from the end of the array:

       
       
    1. <?
    2. /* First, create an array */
    3. $FruitArray=Array("Apple", "orange", "banana", "Peach", "pear ");
    4. /* Use the array_pop () function to delete an element from the end of the array */
    5. $Popped=Array_pop($ FruitArray );
    6. /* Now we display the keys and values of all elements in the deleted array on the webpage */
    7. While (list ($ key, $ value) = each ($ fruitArray )){
    8. Echo "$ key: $ value <br> ";
    9. }
    10. Echo "<br> Finally, the deleted element value is stored in the $ popped variable. its value is $ popped ";
    11. ?>

    The result is 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, whose value is pear.


    Bytes. Next we will introduce how to delete array elements at the end of an array. First, we...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.