Bug #60574 [Com]: range() returns array of integers when arguments are numeric strings

From: Date: Thu, 29 Dec 2011 01:16:14 +0000
Subject: Bug #60574 [Com]: range() returns array of integers when arguments are numeric strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-166124@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60574&edit=1

 ID:                 60574
 Comment by:         hanskrentel at yahoo dot de
 Reported by:        login dot naitsirch at arcor dot de
 Summary:            range() returns array of integers when arguments are
                     numeric strings
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Windows 7
 PHP Version:        5.3.8
 Block user comment: N
 Private report:     N

 New Comment:

This is already documented:

4.1.0 to 4.3.2	 In PHP versions 4.1.0 through 4.3.2, range() sees numeric strings 
as strings and not integers. Instead, they will be used for character sequences. 
For example, "4242" is treated as "4".


Previous Comments:
------------------------------------------------------------------------
[2011-12-20 11:39:15] login dot naitsirch at arcor dot de

Description:
------------
Hi.
I think the 'range()' function should return an array with strings, if the
'start' and 'limit' arguments are numeric strings. Otherwise it should be
mentioned in the documentation.

Test script:
---------------
<?php
var_dump(range('0', '9'));

Expected result:
----------------
array(10) {
  [0]=> string(1) "0"
  [1]=> string(1) "1"
  [2]=> string(1) "2"
  [3]=> string(1) "3"
  [4]=> string(1) "4"
  [5]=> string(1) "5"
  [6]=> string(1) "6"
  [7]=> string(1) "7"
  [8]=> string(1) "8"
  [9]=> string(1) "9"
}

Actual result:
--------------
array(10) {
  [0]=> int(0)
  [1]=> int(1)
  [2]=> int(2)
  [3]=> int(3)
  [4]=> int(4)
  [5]=> int(5)
  [6]=> int(6)
  [7]=> int(7)
  [8]=> int(8)
  [9]=> int(9)
}


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



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


Thread (4 messages)

« previous php.bugs (#166124) next »