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!