3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'abcd,abed,abfd,abgd'; if(preg_match("/ab.d/",$str ,$matches) !== false){ // check any match found or not echo "match found:".$matches[0]; // when found print that match }//after printing execution will stops successfully. ?>

preferences:
15.93 ms | 402 KiB | 5 Q