3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function key_compare_func($key1, $key2) { if ($key1 == $key2) return 0; else if ($key1 > $key2) return 1; else return -1; } $a=new stdClass; $a->{"0"}=1; $a->n=2; var_dump(array_diff_key((array)$a, ["0"=>0])); var_dump(array_diff_ukey((array)$a, [], 'key_compare_func'));
based on 2MCRY
Output for 7.2.0
array(1) { ["n"]=> int(2) } array(2) { [0]=> int(1) ["n"]=> int(2) }
Output for 5.4.10 - 7.1.10
array(2) { ["0"]=> int(1) ["n"]=> int(2) } array(2) { ["0"]=> int(1) ["n"]=> int(2) }
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Ui1jq on line 16
Process exited with code 255.