Array numeric string as key
| Bug #69125 | Array numeric string as key | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2015-02-26 13:23 UTC | Modified: | 2015-02-26 13:37 UTC |
|
||||||
| From: | dm@php.net | Assigned: | ||||||||
| Status: | Closed | Package: | opcache | |||||||
| PHP Version: | 5.6.6 | OS: | Ubuntu 14.04 | |||||||
| Private report: | No | CVE-ID: | None | |||||||
[2015-02-26 13:23 UTC] 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)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2015-02-26 13:25 UTC] dm@php.net
-Package: optimizer +Package: opcache
[2015-02-26 13:37 UTC] dm@php.net
[2015-02-27 01:37 UTC] edgar dot r dot sandi at gmail dot com