Firstly you'll need to parse the page into a DOM. Assuming (for example) you have the page in a variable called $html, you can do:
$document = new DOMDocument;
$document->loadHTML($html);
If the document doesn't contain a http-equiv meta content-type tag, it will probably assume the document is in latin1 encoding (NOTE: Check this). You may need to add such a meta tag to have some pages processed correctly.
After you've got a DOM, you can quite easily just find all the anchors:
$anchors = $document->getElementsByTagName("a");
foreach ($anchors as $node) {
$href = $node->getAttribute("href");
// Assuming $href is set at this point, it will give you a Relative URL (or perhaps fragment e.g. #top)
Sadly there is no standard PHP function to calculate an absolute URL from a base and a relative URL - you'll have to write that yourself (Hint: It's not easy.)
Mark