PHP 2 ways to get the last value of an array, array of 2 _php tutorials

Source: Internet
Author: User

PHP gets 2 methods of the last value of the array, array of 2


Copy the Code code as follows:
$array =array (1,2,3,4,5);
Echo $array [Count ($array) -1];//computes the length of the array, and then gets the last element of the array, if the last element in the array contains a non-numeric key name, the result may not match the expected
Applies to arrays with key names as numbers
Echo '
';
Echo End ($array);//The inner pointer of the array points to the last cell, for all arrays

http://www.bkjia.com/PHPjc/945711.html www.bkjia.com true http://www.bkjia.com/PHPjc/945711.html techarticle PHP Gets the last value of the array of 2 methods, the array of 2 copy code code is as follows: $array =array (1,2,3,4,5); Echo $array [Count ($array) -1];//computes the length of the array, and then gets the array of the most ...

  • Related Article

    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.