php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46631 range() should return low value even if low + step > high
Submitted: 2008-11-20 15:36 UTC Modified: 2008-11-25 19:48 UTC
From: oistein dot notnas at mtu dot no Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.6 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: oistein dot notnas at mtu dot no
New email:
PHP Version: OS:

 

 [2008-11-20 15:36 UTC] oistein dot notnas at mtu dot no
Description:
------------
If the start value is lower then the max value, you should get one result even if the step makes it unable to return 2 values. 

Instead of 
$list = range($i * 2, TOP, $i);

I have to write
if (TOP > ($i * 3))
        $list = range($i * 2, TOP, $i);
    else 
        $list = array($i * 2);

could not even use
$list = @range($i * 2, TOP, $i) or array($i * 2);

Reproduce code:
---------------
print_r(range(6, 8, 3));

Expected result:
----------------
Array
(
    [0] => 6
)

Actual result:
--------------
Warning: range(): step exceeds the specified range

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-25 19:48 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 09:01:32 2025 UTC