PHP next() Function

The next() function is used to advance the internal array pointer. next() behaves like current(), with one difference. It advances the internal array pointer one place forward before returning the element value.

Returns the value of the next element in the array on success, or FALSE if there are no more elements

Parameter Description
array Required. Specifies the array to use

Syntax

next(array) 

Example

$people = array("Cooper","Samuel","James");
echo current($people) . "<br>";
echo next($people);

Output

Cooper
Samuel

Leave a Reply

Your email address will not be published. Required fields are marked *