php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #54696 Error: If low > high, the sequence will be from high to low
Submitted: 2011-05-09 16:51 UTC Modified: 2011-05-24 22:22 UTC
From: Andy at Azurite dot co dot uk Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2011-05-09 16:51 UTC] Andy at Azurite dot co dot uk
Description:
------------
---
From manual page: http://www.php.net/function.range#Return Values
---
The description of a decrementing range is at best ambiguous, at worst wrong:
"If low > high, the sequence will be from high to low."

Having defined 'low' to be the first arg and 'high' to be the 2nd arg, it is 
reasonable, though potentially confusing to consider "low > high" (confusing 
because 'low' is actually higher than 'high' in natural language).  However to 
then 
state that the sequence is from 'high' (the smaller value) to 'low' (the greater 
value) is wrong.

It would be much better if the names low and high were completely replaced with 
'first' and 'last' (or maybe 'limit', to account for ranges that don't exactly 
divide by the increment).  This would be semantically correct in both the 
ascending 
and descending case and completely unambiguous.

It would even be semantically better in terms of inclusivity where the 
comparison 
with the common zero-based form of 'for' loop might lead us to expect the top 
value 
to be exclusive: for ($x=0; $x<10; $x++)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-24 22:14 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=311397
Log: clarify range() parameter purposes (doc #54696)
 [2011-05-24 22:22 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2011-05-24 22:22 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Low/high has been changed to start/limit. Hopefully that clarifies things a 
little.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 06 16:00:01 2026 UTC