Get the current array value in the PHP array Getting Started tutorial

Source: Internet
Author: User
This article describes the PHP array to take the current array of values of the method, there is a need for a friend reference.

In the operation of the PHP array, you can use the current () function to return the array value in the array where the pointer is currently located.

The form is as follows: Mixed current (array array)

For example, get the array value:

 
      "Red", "banana" = "yellow");  while ($fruit = current ($fruits)) {  
", $fruit); Next ($fruits); } by bbs.it-home.org//Red //Yellow ?>

The definition and usage of the current function.

Define and use the current () function to return the element (cell) in the array. Each array has an internal pointer to its "current" element, which initially points to the first element inserted into the array. The current () function returns the value of the array element that is currently pointed to by the internal pointer and does not move the pointer. If the internal pointer points beyond the end of the cell list, current () returns FALSE.

Syntax current (array)

Parameter description array required. Specifies the array to use.

Hints and Comment comments: If there are empty elements, or the element has no value, the function also returns FALSE. Tip: The function does not move the internal pointer. To do this, use the next () and Prev () functions.

Example:

 
      ";//by bbs.it-home.org?>

Output Result: Peter

about using current () to get the contents of the array, this is what we want to help everyone.

  • 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.