php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: paul at stunning-stuff dot com
New email:
PHP Version: OS:

 

 [2006-07-28 01:33 UTC] paul at stunning-stuff dot com
Description:
------------
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 20:09 UTC] vrana@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 18:01:28 2024 UTC