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 ? 1 : -1); }); var_dump($r);
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/S99Up:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/S99Up(5): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/S99Up 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/S99Up:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/S99Up(10): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/S99Up 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/S99Up:9 Stack trace: #0 [internal function]: {closure}('321', '123') #1 /in/S99Up(10): array_udiff_assoc(Array, Array, Object(Closure)) #2 {main} thrown in /in/S99Up on line 9
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/S99Up 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.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
array(2) { ["b"]=> string(3) "321" ["c"]=> array(1) { ["asdf"]=> string(4) "asdf" } }

preferences:
222.3 ms | 403 KiB | 228 Q