$result = preg_match("#^startText(.*)$#i", $string); if($result == 0) { echo "No match"; } else { echo "Match found."; }
PHP.net regular expressions
preg_match returns either 0 for matches found, or 1 , because preg_match stops at the first match. If you want to read all matches, use preg_match_all .
Check out the PHP site if you have more problems.
source share