php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60574 range() returns array of integers when arguments are numeric strings
Submitted: 2011-12-20 11:39 UTC Modified: 2012-03-03 19:45 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: login dot naitsirch at arcor dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.8 OS: Windows 7
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: login dot naitsirch at arcor dot de
New email:
PHP Version: OS:

 

 [2011-12-20 11:39 UTC] 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)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-29 01:16 UTC] hanskrentel at yahoo dot de
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".
 [2011-12-29 12:42 UTC] login dot naitsirch at arcor dot de
This is not clear enough, in my opinion.
Another question: Why should numeric strings be seen as integers and not as strings?
 [2012-03-03 19:45 UTC] iliaa@php.net
-Status: Open +Status: Not a bug
 [2012-03-03 19:45 UTC] iliaa@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: Tue Jul 15 01:01:35 2025 UTC