|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66793 range(0,9) and range('0','9') both produce intergers in array
Submitted: 2014-02-27 23:52 UTC Modified: 2014-02-28 10:33 UTC
From: araustin at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.4.25 OS: Win 8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: araustin at gmail dot com
New email:
PHP Version: OS:


 [2014-02-27 23:52 UTC] araustin at gmail dot com
From manual page:

Test script:
$allowedChars_num = range(0,9);
$allowedChars_str = range('0','9');

Expected result:
range(0,9) is proper, making an array of integers
range('0','9') should be making an array of strings, ex: '0','1','2' etc...

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) } 

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) } 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-28 10:33 UTC]
-Status: Open +Status: Wont fix
 [2014-02-28 10:33 UTC]
That may sound logic for your particular example, however if you spread it with say range('24','42'), it'll become inconsistent. Concatenation with integer still works, and the way it's handled now is consistent - numeric strings become numbers, it was introduced somewhere in PHP-4 according to the doc page. And btw that is platform independent behavior.
 [2014-02-28 10:33 UTC]
-Status: Wont fix +Status: Not a bug
 [2014-02-28 21:10 UTC] a dot r dot austin at gmail dot com
You say that what about range('24','42') ??? Well, it is the same as to ask what about range('pk','rt')... It does not make sense. If is it a string, it should be an ascii character, one char long. 

range('24','42') should be error of some sorts just like range('pk','rt')
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 18:01:36 2024 UTC