3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tmp = json_decode(json_encode( (object) array('cars' => (object) array("1" => "one")) )); // 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($cars); $cars = array('1' => 'WTF'); var_dump(array_key_exists("1", $cars)); // expected true, returns true var_dump(array_key_exists(1, $cars)); // expected true, returns true
based on ctO4R
Output for 7.2.0 - 7.3.1
bool(true) bool(true) array(1) { [1]=> string(3) "one" } bool(true) bool(true)
Output for 5.4.0 - 5.6.38, 7.0.17 - 7.0.33, 7.1.3 - 7.1.25
bool(false) bool(false) array(1) { [1]=> string(3) "one" } bool(true) bool(true)
Output for 7.0.0 - 7.0.16, 7.1.0 - 7.1.2
bool(false) bool(false) array(1) { ["1"]=> string(3) "one" } bool(true) bool(true)