3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tmp = json_decode(json_encode( (object) array('cars' => (object) array("1" => "one")) )); var_dump($tmp->cars); // expected $cars = array("1" => "one"); $cars = (array) $tmp->cars; var_dump(array_key_exists("1", $cars)); // expected true, returns false var_dump(array_key_exists(1, $cars)); // expected true, returns false $cars = get_object_vars($tmp->cars); var_dump(array_key_exists("1", $cars)); // expected true, returns true var_dump(array_key_exists(1, $cars)); // expected true, returns true
based on IdBd1
Output for 7.2.0
object(stdClass)#2 (1) { ["1"]=> string(3) "one" } bool(true) bool(true) bool(true) bool(true)
Output for 7.0.20, 7.1.5 - 7.1.10
object(stdClass)#2 (1) { ["1"]=> string(3) "one" } bool(false) bool(false) bool(true) bool(true)
Output for 7.0.0 - 7.0.9, 7.1.0
object(stdClass)#2 (1) { ["1"]=> string(3) "one" } bool(false) bool(false) bool(false) bool(false)
Output for 5.4.0 - 5.6.28
object(stdClass)#1 (1) { ["1"]=> string(3) "one" } bool(false) bool(false) bool(true) bool(true)