3v4l.org

run code in 300+ PHP versions simultaneously
<?php function anyKeyExists($haystack, $needles) { foreach ($needles as $needle) { if (isset($haystack[$needle])) { return true; } } return false; } $array = [ "keyA" => 1, "keyB" => 2, "keyC" => 3 ]; echo "noMatch: " , (int)anyKeyExists($array, ['keyD', 'keyF']) , "\n"; echo "oneMatch: " , anyKeyExists($array, ['keyB', 'keyD']) , "\n"; echo "twoMatches: " , anyKeyExists($array, ['keyA', 'keyC']) , "\n";

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
151.67 ms | 2121 KiB | 11 Q