Re: PHP 4.0 Bug #8325: numeric strings used as keys are converted to longs
| From: | Cynic | Date: | Tue, 19 Dec 2000 22:30:17 +0000 |
| Subject: | Re: PHP 4.0 Bug #8325: numeric strings used as keys are converted to longs | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-41858@lists.php.net to get a copy of this message | ||
My PHP (php4apache.dll 4.0.4 RC6) outputs quoted string (and
double, for that matter) keys in var_dump().
actual example:
array(3) {
[1]=> string(4) "aaaa"
["a2"]=> string(3) "bbb"
["3.5"]=> string(6) "cccccc"
}
At 23:15 19.12. 2000, Ignacio Vazquez-Abrams wrote the following:
--------------------------------------------------------------
>On 19 Dec 2000 cynic@mail.cz wrote:
>
>> From: cynic@mail.cz
>> Operating system: *
>> PHP version: 4.0 Latest CVS (19/12/2000)
>> PHP Bug Type: Feature/Change Request
>> Bug description: numeric strings used as keys are converted to longs
>>
>> (Actually, this is for PHP 4 versions up to 4.0.4 RC6, but it ain't in the version
>> list.)
>>
>> I don't want to sound harsh or something, and this behavior seemed to be accepted as
>> feature from what I saw elsewhere in the bug database (can't find it, though), but I think it
>> shouldn't be that way.
>>
>> Current behavior:
>>
>> <?
>> $p = 1 ;
>> settype( $p , 'string' ) ;
>> $a = array( $p => 'aaaa' ) ;
>> var_dump( $a ) ;
>> ?>
>>
>> output (note: casting within the array() doesn't help):
>> string(1) "1"
>> array(1) {
>> [1]=>
>> string(4) "aaaa"
>> }
>>
>>
>> 'Right' (YMMV) behavior:
>> string(1) "1"
>> array(1) {
>> ["1"]=>
>> string(4) "aaaa"
>> }
>>
>
>Actually, this behavior is displayed for any key, i.e., if the key is a
>string (e.g., "name"), it is displayed without quotes.
>
>--
>Ignacio Vazquez-Abrams <ignacio@openservices.net>
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
>For additional commands, e-mail: php-dev-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz