|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #38240 Change prev() and next() documentation
Submitted: 2006-07-28 01:33 UTC Modified: 2007-08-25 01:00 UTC
From: paul at stunning-stuff dot com Assigned:
Status: No Feedback Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-07-28 01:33 UTC] paul at stunning-stuff dot com
The documentation for prev() states the following:

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

After reading this I was expecting prev() to only change the array pointer's position if there is a previous element and return false (without changing the pointer's position) if there isn't a previous element.

This misconception caused a bug in my code and it took me quite some time to figure out the problem.

I would suggest you change the text to make it less ambiguous.

The next() documentation is a little more clear, but could also use some disambiguation.

Bug report #37598 shows that I am not the only one who misunderstood the docs. The final paragraph in the final post in that bug report is a good explanation of how prev() and next() work:

"You should check the return value of prev and next. The state is
undefined as out of range. Reset the array after having reached the end
or beginning."

Thanks for your time and effort,

Paul van der Maas


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 20:09 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

 [2007-08-25 01:00 UTC] phpdoc at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 17:01:24 2021 UTC