3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a=array("a"=>"red","b"=>"green","c"=>"blue"); $found = false; $string = "red"; foreach($a as $item) { if($found == false) { preg_match("/$string/",$item); } } echo $found; ?>

preferences:
34.16 ms | 402 KiB | 5 Q