3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ "ABwerty45^&*jk", "ABwerrtty", "LF%$^erftgt5234", "TABYR56H", "ab7877", "Abtyu7" ]; $arr = ['AB', 'DC', 'LF']; foreach ($strings as $string) { $match = in_array(substr($string, 0, 2), $arr); echo $match ? "Match: $string" . PHP_EOL : "No match: $string" . PHP_EOL; }

preferences:
66.71 ms | 402 KiB | 5 Q