Home >Backend Development >PHP Tutorial >PHP array PHP array function sequence next - moves the internal pointer of the array to the position of the next element and returns the element value
next() Definition and usage
next() function moves the pointer pointing to the current element to the position of the next element and returns the value of the element.
If the internal pointer has exceeded the last element of the array, the function returns false.
Syntax
next(array) Parameter Description
array Required. Specifies the array to use.
Explanation
next() behaves similarly to current(), with one difference: the internal pointer is moved forward one bit before returning the value. This means that it returns the value of the next array element and moves the array pointer forward one position. If the result of moving the pointer is beyond the end of the array element, next() returns FALSE.
Note: If the array contains empty cells, or the value of the cell is 0, this function will also return FALSE when encountering these cells. To correctly iterate over an array that may contain empty cells or a cell value of 0, see the each() function.
Example
Copy code The code is as follows:
$people = array("Peter", "Joe", "Glenn", "Cleveland");
echo current($people) . "
";
echo next($people);
?>
The above introduces the PHP array PHP array function sequence next - moves the internal pointer of the array to the position of the next element and returns the element value, including the PHP array content. I hope it will be helpful to friends who are interested in PHP tutorials.