Get the value of the first element of an unknown character keys array group by using the PHP current function _php tips

Source: Internet
Author: User
About the current () function:

Each array has an internal pointer to its "current" cell, which initially points to the first cell inserted into the array. Gets with current ().

Similar functions:

End () Moves the internal pointer of the array to the last cell and returns its value.

Next () returns the value of the next cell that the array's internal pointer points to, or false when there are no more cells.

Prev () returns the value of the previous cell pointed to by an array's internal pointer, or FALSE if there are no more cells.

Reset () returns the array's internal pointer back to the first cell and returns the value of the first array cell, False if the array is empty.

Look at the following PHP case:

Copy Code code 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 PHP is also
Echo End ($arr); C
?>


Very handy and very useful PHP functions, anyway, 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.