For some reason coding usually comes easy to me, but I can't for the life of me figure out preg's. I should take some time and study it because it's very useful. Anyways here is a simple script I found to check a back link on another site. I want to modify this code to check not only for a back link but also a rel="nofollow" tag. How would I edit this code to do that? Thanks function check_back_link($remote_url, $your_link) { $match_pattern = preg_quote(rtrim($your_link, "/"), "/"); $found = false; $nofollow = false; if ($handle = @fopen($remote_url, "r")) { while (!feof($handle)) { $part = fread($handle, 1024); if (preg_match("/<a(.*)href=[\"']".$match_pattern. "(\/?)[\"'](.*)>(.*)<\/a>/", $part)) { $found = true; break; } } fclose($handle); } return $found; } PHP:
function check_back_link($remote_url, $your_link) { $match_pattern = preg_quote(rtrim($your_link, "/"), "/"); $found = false; $nofollow = false; if ($handle = @fopen($remote_url, "r")) { while (!feof($handle)) { $part = fread($handle, 1024); if (preg_match("/<a(.*)href=[\"']".$match_pattern. "(\/?)[\"'](.*)>(.*)<\/a>/", $part, $match)) { print_r($match); if (preg_match("/rel=[\"']?nofollow[\"']?/", $match[0])) $found = false; else $found = true; break; } } fclose($handle); } return $found; } PHP: