php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17565 optional ORDER parameter for range()
Submitted: 2002-06-02 05:52 UTC Modified: 2013-07-12 12:44 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: bigredlinux at yahoo dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.2.1 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-06-02 05:52 UTC] bigredlinux at yahoo dot com
The range() function has the ability to generate a range from one number (or character) to another.  It states in the documentation that if the first number (character) is greater than the second, it creates a decreasing range.  However, the problem is, sometimes you don't want it to switch range order, so it would be nice to have a third parameter which states the direction or states whether you want it to auto flip.  Hence, if I did

range(9, 0, ASC)

it would generate an empty array...

or prehaps I could do

range(9, 0, false)

for not autoflipping.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-23 14:42 UTC] datibbaw@php.net
range() now has that option since 5.0, though it will still assume the step size 
is negative when the start value is higher than the end value.
 [2013-07-12 12:44 UTC] maarten@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2013-07-12 12:44 UTC] maarten@php.net
Just add an if condition for your business rules where you expect an empty array.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC