php / php/doc-en

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

Open
#1,559 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: standard
Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PHP manual page for next(), linked in the issue, and review the related prev() behavior and example. Update the documentation so the pointer behavior and the intended outcome of the example are unambiguous, then verify that the revised wording matches the manual's conventions.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.