Php operations on array functions current, next, and reset function Usage examples

Source: Internet
Author: User
In php, the current () function returns the current element (unit, which is the first element of the array. the next () function points the internal pointer to the next element in the array, and output the value of this element. The reset () function points internal pointers to the first element in the array and outputs the value of this element. This article mainly introduces the usage of current, next, and reset functions in php, and details the usage of current, next, and reset functions for array operations in PHP in the form of instances, it has some reference value for in-depth understanding of array usage, and I hope it will help you understand arrays. What are the functions of php current, next, and reset?

In php, the current () function returns the current element (unit, which is the first element of the array. the next () function points the internal pointer to the next element in the array, and output the value of this element. The reset () function points internal pointers to the first element in the array and outputs the value of this element. This article mainly introduces the usage of current, next, and reset functions in php, and details the usage of current, next, and reset functions for array operations in PHP in the form of instances, it has some reference value for in-depth understanding of array usage, and I hope it will help you understand arrays.

Current function

The current () function returns the value of the current element in the array. Each array has an internal pointer pointing to its "current" element, initially pointing to the first element inserted into the array. This function does not move the internal pointer of the array.

Example

 ";?>

Code running result:

Next function

The next () function points an internal pointer to the next element in the array and outputs the value of this element.

Example

Use the php current and next functions to output the values of the current and next elements in the array: the code is as follows:

 ";echo next($people);?>

Code running result:

Reset function

The set () function points internal pointers to the first element in the array and outputs the value of this element.

Example

Use the php current and next functions to output the values of the current and next elements in the array, and then reset the internal pointer of the array to the first element in the array. The code is as follows:

 ";echo next($people) . "
";echo reset($people);?>

Code running result:

[Recommended related articles]

Php array function current () definition and usage

Php end () and current () functions

The above is a detailed description of the usage examples of php array functions current, next, and reset functions. For more information, see other related articles in the first PHP community!

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.