3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $json = '{"1":"A"}'; $arrWorks = json_decode($json, true); var_dump($arrWorks); var_dump($arrWorks[1], $arrWorks['1']); echo "\n=================\n"; $arrDoesntWork = get_object_vars(json_decode($json)); var_dump($arrDoesntWork); var_dump($arrDoesntWork[1], $arrDoesntWork['1']);
based on Y9JGC
Output for 5.5.0 - 5.6.29, 7.0.20, 7.1.5 - 7.2.8
array(1) { [1]=> string(1) "A" } string(1) "A" string(1) "A" ================= array(1) { [1]=> string(1) "A" } string(1) "A" string(1) "A"
Output for 7.0.0 - 7.0.14, 7.1.0
array(1) { [1]=> string(1) "A" } string(1) "A" string(1) "A" ================= array(1) { ["1"]=> string(1) "A" } Notice: Undefined offset: 1 in /in/bbleq on line 12 Notice: Undefined offset: 1 in /in/bbleq on line 12 NULL NULL