Getting the current array value in the php array Getting Started Tutorial

Source: Internet
Author: User
Getting the current array value in the php array Getting Started Tutorial
This article describes how to obtain the current array value of a php array. For more information, see.

In the php array operation, you can use the current () function to return the array value of the current pointer position in the array.

The format is as follows: mixed current (array)

For example, obtain the array value:

     "red", "banana"=>"yellow");  while ($fruit = current($fruits)) {  printf("%s 
", $fruit); next($fruits); } // by bbs.it-home.org// red // yellow ?>

Define and use the current function.

Define and use the current () function to return the current element (unit) in the array ). Each array has an internal pointer pointing to its "current" element, initially pointing to the first element inserted into the array. The current () function returns the value of the array element to which the current internal pointer points, without moving the pointer. If the internal pointer points to an end that exceeds the cell List, current () returns FALSE.

Syntax current (array)

The parameter description array is required. Specifies the array to be used.

Tip and comment: if the element is empty or has no value, the function returns FALSE. Tip: This function does not move internal pointers. To do this, use the next () and prev () functions.

Example:

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

Output result: Peter

This article describes how to use current () to obtain the current value of the array. We hope this will help you.

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.