PHP - Get All Links from a Website

Below is a quick little script for PHP that will grab all the links in a page and output them in a human-readable format. Nothing special, but useful.

    $html = file_get_contents('http://www.example.com');

    $dom = new DOMDocument();
    @$dom->loadHTML($html);

    $xpath = new DOMXPath($dom);
    $hrefs = $xpath->evaluate("/html/body//a");

    for ($i = 0; $i < $hrefs->length; $i++) {
		$href = $hrefs->item($i);
		$url = $href->getAttribute('href');
		echo $url.'<br />';
    }
ender