3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['a' => '123', 'b' => '321', 'c' => ['asdf' => 'asdf']]; $b = ['a' => '123', 'b' => '123', 'c' => ['asdf' => 'asdf123']]; $r = array_udiff_assoc($a, $b, function($old, $new) { if ($old === $new) { return 0; } return (count($old) > $new ? $old : $new); }); var_dump($r);
Output for 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/pvVLt:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/pvVLt(5): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/pvVLt on line 9
Process exited with code 255.
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/pvVLt:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/pvVLt(10): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/pvVLt on line 9
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given in /in/pvVLt:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/pvVLt(10): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/pvVLt on line 9
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/pvVLt on line 9 array(2) { ["b"]=> string(3) "321" ["c"]=> array(1) { ["asdf"]=> string(4) "asdf" } }
Output for 5.4.0 - 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
array(2) { ["b"]=> string(3) "321" ["c"]=> array(1) { ["asdf"]=> string(4) "asdf" } }

preferences:
274 ms | 402 KiB | 378 Q