PHP Combine Patterns With Pipe (|) Character To Create Branches – String Function

<?
$test = "www.example.com";
if ( preg_match( "/www\.example(\.com|\.co\.uk)/", $test, $array ) ) {
  print "it is a $array[1] domain<br/>";
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.