I'm looking to use preg_match to find: href="http://mostplays.com" On a page. However I'm not sure exactly how to do that with preg_match. Basically if it finds it on a page then show true, else show false. Probably very simple with and if else.
If you are searching for exact string, strpos is faster and more preferable than preg_match. Use if (strpos($text,'href="http://mostplays.com"') !== false) echo 'exists'; else echo 'no'; PHP:
preg_match will return 1 if a match is found or false/zero otherwise, so you can safely do something like this logic-wise with preg_match. if(preg_match(...)) { // do stuff } Code (markup): If you're searching for an exact string, use strpos or stripos like wmtips suggested. However, if this is for something like a backlink verification where site owners may vary the way they enter their HTML, pattern matching is easier to maintain than a strpos loop. if(preg_match('#href\s*=\s*([\'"])http://domain\.com/$1#i', $str)) { } Code (markup):