Home >>PHP Array Functions >PHP next() Function
PHP next() Function is used to return the value of the next element in an array which the internal pointer is currently pointing to. It increments the internal pointer after returning the value. It accepts only a single parameter $array that is the given input array.
Syntax:
: next($array);
Parameter | Description |
---|---|
array | This is a required parameter. It defines the array to use. |
Here is an example of next() function in PHP:
<html> <body> <?php $x = array("A","B","C","D","E","F","G"); echo "Current : ".current($x) . "<br>"; echo "Next : ".next($x); ?> </body> </html>
Example 2:
<html> <body> <?php $x = array("A","B","C","D","E","F","G"); echo "Current : ".current($x)."<br>"; echo "Next : ".next($x)."<br>"; echo "Current : ".current($x)."<br>"; echo "End : ".end($x)."<br>"; echo "Current : ".current($x)."<br>"; echo "Reset : ".reset($x)."<br>"; echo "Next : ".next($x); ?> </body> </html>