#46631 [Opn]: range() should return low value even if low + step > high

From: Date: Tue, 25 Nov 2008 14:53:34 +0000
Subject: #46631 [Opn]: range() should return low value even if low + step > high
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131304@lists.php.net to get a copy of this message
 ID:               46631
 User updated by:  oistein dot notnas at mtu dot no
 Reported By:      oistein dot notnas at mtu dot no
 Status:           Open
-Bug Type:         Feature/Change Request
+Bug Type:         Arrays related
 Operating System: Windows XP
 PHP Version:      5.2.6
 New Comment:

Changed category.


Previous Comments:
------------------------------------------------------------------------

[2008-11-20 15:36:25] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46631&edit=1



Thread (3 messages)

« previous php.bugs (#131304) next »