View Single Post
Old 08-01-2009, 03:09 PM  
nation-x
Confirmed User
 
nation-x's Avatar
 
Industry Role:
Join Date: Mar 2004
Location: Rock Hill, SC
Posts: 5,370
Here is the final version for anyone that might need something similar... we found that there was a small issue with urls that had an ending slash... fixed.
Code:
<?php
$url = 'http://www.crazyfilth.com';
$anchor_text = 'Porn Videos';
$html = file_get_contents('http://aisle69.com/');

echo checkUrl($url, $anchor_text, $html);

function checkUrl($url, $anchor_text, $html) {
	$found = false;
	$dom = new domDocument(); 
	@$dom->loadHTML($html); 
	$anchors = $dom->getElementsByTagName('a'); 
	foreach ($anchors as $anchor) { 
		 $found_url = preg_replace('{/$}', '', $anchor->getAttribute('href'));
		 $urltext = trim($anchor->nodeValue);
		 if (($found_url == $url) && ($anchor_text == $urltext))  {
				return true;
		 }
	}
	return false;
}
?>
nation-x is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote