I am building a crawler which starts from a webpage of website, say example.com, and find all the links on this page which are on same domain.
So suppose we have example.com/hello.php, facebook.com/hello.php on this page. So I only want to list www.example.com/hello.php.
I am using PHP Simple HTML DOM Parser(simplehtmldom.sourceforge.net/).
$html = file_get_html('http://www.example.com/');
// Find all links
foreach($html->find('a') as $element) {
$uri = $element->href;
//Now how to check if $uri belongs to same domain?
}