PHP Array Functions

next() Function

Definition and Usage

The next() function moves the internal pointer to, and outputs, the next element in the array.

Every array has an internal pointer to its "current" element, which is initialized to the first element inserted into the array.


Syntax

next(array)


Parameter Description
array Required. Specifies the array to use

Example

Output the value of the current and the next element in the array:

<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");

echo current($people) . "<br>";
echo next($people);
?>

Run Example>>