simple string search in php

<?php
$string_to_search = "w3mentor.com";
$regex = "/tor/";
$num_matches = preg_match($regex, $string_to_search);
 
if ($num_matches > 0) {
  echo "Found a match!";
} else {
  echo "No match. Sorry.";
}
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.