HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

next

Description

The next of Array for PHP advances the internal pointer of an array.

Syntax

next(
    array|object &$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 · next

<?

$array =
[
    0,
    1,
    2
];

$return = next($array);

echo $return;
1

2 · multiple

<?

$array =
[
    0,
    1,
    2,
    3,
    4
];

foreach($array as $value)
{
    echo next($array) . PHP_EOL;
}
1
2
3
4

3 · beyond

<?

$array =
[
    0,
    1,
    2
];

end($array);

$return = next($array);

var_export($return);
false

4 · empty

<?

$array = [];

$return = next($array);

var_export($return);
false