Mega Code Archive

 
Categories / Php / Strings
 

String matches

<?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!");      }      ?>