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

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

WBOY
Release: 2016-07-29 08:47:06
Original
1523 people have browsed it

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);
?>


Output:
Peter
Joe

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template