3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ 'abc' => 46, 'def' => 134, 'xyz' => 34, //'qwe' => 39, ]; $array2 = [ 'abc' => 46, 'def' => 134, 'xyz' => 34, 'qwe' => 39, ]; function allKeysFoundInBothArrays(array $array1, array $array2): bool { foreach ($array1 as $key => $notUsed) { echo "checking $key in \$array2\n"; if (!key_exists($key, $array2)) { return false; } unset($array2[$key]); } foreach ($array2 as $key => $notUsed) { echo "checking $key in \$array1\n"; if (!key_exists($key, $array1)) { return false; } } return true; } var_export(allKeysFoundInBothArrays($array1, $array2));
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.28, 8.4.1 - 8.4.14, 8.5.0
checking abc in $array2 checking def in $array2 checking xyz in $array2 checking qwe in $array1 false
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
139.81 ms | 407 KiB | 5 Q