PHP String Matches: String Start – String Function

 
    <?php
     $pattern = "/^PHP$/";$string = "   PHP   ";
     if(preg_match($pattern, $string)){
          print("Found a match!");
     }
 
     $string = "PHP is ";
     if(preg_match($pattern, $string)){
          print("This line won't print!");
     }
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.