Use the PHP current function to obtain the value of the first element of the array with an unknown character key name

Source: Internet
Author: User

About current () functions:

Each array has an internal pointer pointing to its "current" unit, initially pointing to the first unit inserted into the array. Use current.

Similar functions:

End () moves the internal pointer of array to the last unit and returns its value.

Next () returns the value of the next unit pointed to by the internal pointer of the array, or FALSE if no more units exist.

Prev () returns the value of the previous Unit pointed to by the internal pointer of the array, or FALSE if there are no more units.

Reset () returns the internal pointer of array to the first unit and the value of the first array unit. If the array is null, FALSE is returned.

See the following PHP case:

Copy codeThe Code is as follows: <? Php
$ Arr = array ("a" => "php", "java", "c ");
Echo current ($ arr); // php
Echo next ($ arr); // java
Echo prev ($ arr); // php points to the value of the previous unit, so it is php again
Echo end ($ arr); // c
?>

Several useful and useful php functions I remember.

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.