I am creating a script that gets all links from an website and checking every link if is broken. My problem is, I need to display all links founded but I need to verify only the unique links not the duplicate. For example if a website has 4 links to google.com then I want to check only one time not four times.
foreach ($dom->getElementsByTagName('a') as $node) {
$info = $node->getAttribute( 'href' );
///The function that checks for broken links working.
$check_url_status = check_url($info);
if ($check_url_status == '404') {
$badresult = 'Not working';
}else{
$badresult = 'Working';
}
$showlist .= '<li>The '.$info.' is '.$badresult.'</li>';
}
echo '<ul>'.$showlist.'</ul>';
This code is works, but I need to make it check the http status only 1 time for duplicate links.
I do not have idea of how to do this and also if is posible to do something like that.