Bug #66793 [Opn->Wfx]: range(0,9) and range('0','9') both produce intergers in array

From: Date: Fri, 28 Feb 2014 10:33:43 +0000
Subject: Bug #66793 [Opn->Wfx]: range(0,9) and range('0','9') both produce intergers in array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184471@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66793&edit=1

 ID:                 66793
 Updated by:         ab@php.net
 Reported by:        araustin at gmail dot com
 Summary:            range(0,9) and range('0','9') both produce intergers
                     in array
-Status:             Open
+Status:             Wont fix
 Type:               Bug
 Package:            Output Control
 Operating System:   Win 8
 PHP Version:        5.4.25
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2014-02-27 23:52:14] araustin at gmail dot com

Description:
------------
---
From manual page: http://www.php.net/function.range
---


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

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


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



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


Thread (4 messages)

« previous php.bugs (#184471) next »