3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_export([ // haystack, then needle '0:1' => strpbrk('0', '1'), // false '1:0' => strpbrk('1', '0'), // false '0:0' => strpbrk('0', '0'), // '0' '1:1' => strpbrk('1', '1'), // '1' 'a:b' => strpbrk('a', 'b'), // false 'b:a' => strpbrk('b', 'a'), // false 'a:a' => strpbrk('a', 'a'), // 'a' 'b:b' => strpbrk('b', 'b'), // 'b' 'a as bool' => (bool)'a', 'a as int' => (int)'a', 'a as bool then int' => (int)(bool)'a', ]); echo "\n---\n"; $params = [ ['one' => '0', 'two' => '1', 'three' => '0', 'four' => '1', 'five' => 'a', 'six' => 'b', 'seven' => 'a', 'eight' => 'b'], // haystacks ['three' => '0', 'one' => '1', 'four' => '1', 'two' => '0', 'five' => 'a', 'eight' => 'b', 'six' => 'b', 'seven' => 'a'], // needles 'strpbrk' ]; var_export([ 'udiff' => array_udiff_assoc(...$params), 'uintersect' => array_uintersect_assoc(...$params), ]);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
array ( '0:1' => false, '1:0' => false, '0:0' => '0', '1:1' => '1', 'a:b' => false, 'b:a' => false, 'a:a' => 'a', 'b:b' => 'b', 'a as bool' => true, 'a as int' => 0, 'a as bool then int' => 1, ) --- array ( 'udiff' => array ( 'four' => '1', ), 'uintersect' => array ( 'one' => '0', 'two' => '1', 'three' => '0', 'five' => 'a', 'six' => 'b', 'seven' => 'a', 'eight' => 'b', ), )

preferences:
97.27 ms | 408 KiB | 5 Q