3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function key_compare_func($key1, $key2) { var_dump($key1, $key2, $key1 == $key2, $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; echo "key\n"; var_dump(array_diff_key((array)$a, [0])); echo "ukey\n"; var_dump(array_diff_ukey((array)$a, [0], 'key_compare_func'));
based on rNbGX
Output for 7.2.0
key array(1) { ["n"]=> int(2) } ukey int(0) string(1) "n" bool(true) bool(false) int(0) int(0) bool(true) bool(false) string(1) "n" int(0) bool(true) bool(false) array(0) { }
Output for 7.0.0 - 7.1.10
key array(2) { ["0"]=> int(1) ["n"]=> int(2) } ukey string(1) "0" string(1) "n" bool(false) bool(false) string(1) "0" int(0) bool(true) bool(false) string(1) "n" int(0) bool(true) bool(false) array(0) { }
Output for 5.4.10 - 5.6.28
key array(2) { ["0"]=> int(1) ["n"]=> int(2) } ukey string(1) "n" string(1) "0" bool(false) bool(true) string(1) "0" int(0) bool(true) bool(false) string(1) "n" int(0) bool(true) bool(false) array(0) { }
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/k6UaW on line 18
Process exited with code 255.