next

Advance the internal pointer of an array

Syntax

next ( array &$array ) : mixed

Parameters

array

The array being affected.

Return

Returns the array value in the next place that's pointed to by the internal array pointer, or FALSE if there are no more elements.

Examples

1

<?

$array = array('one', 'two', 'three', 'four');

$return = next($array);

echo $return;

?>
two

2

<?

$array = array('one', 'two', 'three', 'four');

echo next($array) . PHP_EOL;
echo next($array) . PHP_EOL;
echo next($array);

?>
two
three
four

3

<?

$array = array('one', 'two', 'three', 'four');

end($array);

$return = next($array);

var_export($return);

?>
false

4

<?

$array = array();

$return = next($array);

var_export($return);

?>
false

Internal

current

end

prev

reset

External

PHP

Home Menu