/* FluidCoding - Searching Author: Tonic */ <?php $string = "Hello World"; //Our string $match = "/\bHello\b/i"; //Our compare for the word Hello if(preg_match($match, $string) !==0); //Checks for match echo "Success! There's a match!"; //If they match, says success! } else { //No match echo "Sorry, no match found"; } ?>
Output
Success! There's a match!