3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array('foo' => 42, 'bar' => null); $obj = new ArrayObject($arr); foreach (array($arr, $obj) as $ao) { var_dump($ao); foreach (array('foo', 'bar', 'qux') as $key) { echo "- '$key'\n"; echo 'isset: '; var_dump(isset($ao[$key])); echo 'array_key_exists: '; var_dump(array_key_exists($key, (array)$ao)); unset($ao[$key]); } var_dump($ao); echo "\n"; }
Output for 7.3.32, 7.4.26, 8.1rc1 - rc3
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { ["foo"]=> int(42) ["bar"]=> NULL } } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 8.0.0 - 8.0.13
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { ["foo"]=> int(42) ["bar"]=> NULL } } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) Warning: Undefined array key "qux" in /in/WVJnf on line 12 object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 5.4.8 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { ["foo"]=> int(42) ["bar"]=> NULL } } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) Notice: Undefined index: qux in /in/WVJnf on line 12 object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 5.3.11 - 5.3.29, 5.4.1 - 5.4.7
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { ["foo"]=> int(42) ["bar"]=> NULL } } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) Notice: Undefined index: qux in /in/WVJnf on line 12 object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 5.3.0 - 5.3.10, 5.4.0
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { ["foo"]=> int(42) ["bar"]=> NULL } } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(true) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) Notice: Undefined index: qux in /in/WVJnf on line 12 object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(0) { } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
array(2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(false) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) array(0) { } object(ArrayObject)#1 (2) { ["foo"]=> int(42) ["bar"]=> NULL } - 'foo' isset: bool(true) array_key_exists: bool(true) - 'bar' isset: bool(true) array_key_exists: bool(true) - 'qux' isset: bool(false) array_key_exists: bool(false) Notice: Undefined index: qux in /in/WVJnf on line 12 object(ArrayObject)#1 (0) { }
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/WVJnf on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/WVJnf on line 4

preferences:
58.85 ms | 471 KiB | 5 Q