Re: Patch for range()
| From: | Jon Parise | Date: | Sat, 23 Nov 2002 07:57:06 +0000 |
| Subject: | Re: Patch for range() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-91477@lists.php.net to get a copy of this message | ||
On Sat, Nov 23, 2002 at 03:37:29PM +0900, Moriyoshi Koizumi wrote:
> I've just found range() behaves unexpectedly in some special cases.
>
> For instance, please try the following script.
>
> <?php
> echo count(range('a', 'z', 12));
> ?>
>
> will give 45 while it should return an array that consists of 3 elements.
> That is because the counting may exceed the upper limit of positive char
> value during the loop.
>
> The attached patch is a fix for this issue. I'll commit this if there are
> no objections.
No objections (although I haven't actually applied and run your
patch). Thanks for investigating this. I should have tested a wider
set of step values in my original tests.
--
Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)