Bug #69125 [Opn]: Array numeric string as key

From: Date: Thu, 26 Feb 2015 13:25:59 +0000
Subject: Bug #69125 [Opn]: Array numeric string as key
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190961@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69125&edit=1 ID: 69125 Updated by: dm@php.net Reported by: dm@php.net Summary: Array numeric string as key Status: Open Type: Bug -Package: optimizer +Package: opcache Operating System: Ubuntu 14.04 PHP Version: 5.6.6 Block user comment: N Private report: N New Comment: Wrong package. Previous Comments: ------------------------------------------------------------------------ [2015-02-26 13:23:08] dm@php.net Description: ------------ Numeric string as array key is allowed (not cast to int) if the key value is passed as constant (or possibly some other way too). This can be achieved by casting object with numeric properties to array, but normally one cannot assign numeric string as array key. Also, isset($array['0']) returns false even tho it exists. (possibly another bug or a feature?) Test script: --------------- <?php const SZERO = '0'; $array[SZERO] = PHP_VERSION; var_dump($array); Expected result: ---------------- array (size=1) 0 => string '5.6.6-1+deb.sury.org~trusty+1' (length=29) Actual result: -------------- array (size=1) '0' => string '5.6.6-1+deb.sury.org~trusty+1' (length=29) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69125&edit=1

« previous php.bugs (#190961) next »