Home > Backend Development > PHP Tutorial > PHP array function sequence next() - moves the internal pointer of the array to the position of the next element and returns the value of the element_PHP tutorial

PHP array function sequence next() - moves the internal pointer of the array to the position of the next element and returns the value of the element_PHP tutorial

WBOY
Release: 2016-07-21 15:23:25
Original
1446 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, moving the internal pointer 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324477.htmlTechArticlenext() Definition and Usage The next() function moves the pointer to the current element to the position of the next element. and returns the value of that element. If the internal pointer has exceeded the last element of the array...
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