Skip to content

Clarify the possibility to lose the array pointer with next() and prev() #1559

Open
@tecdoc-ukr

Description

@tecdoc-ukr

From manual page: https://php.net/function.next


If the next or prev function goes beyond the array, it is not possible to return to the previous (first/last element)!

// example
$array = array(
    'fruit1' => 'apple',
    'fruit2' => 'orange',
    'fruit3' => 'grape',
    'fruit4' => 'apple',
    'fruit5' => 'apple');

reset($array); // prepare array

$row = current($array);
var_dump($row); // 'apple'

$row = prev($array);
var_dump($row); // false

$row = next($array); // it is not possible to return to the previous (first/last element)!
var_dump($row); // false

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions