- file_get_contents: documentation ( source)
- preg_match_all: documentation ( source)
<?php
// Original PHP code by Chirp Internet: www.chirp.com.au
// Please acknowledge use of this code by including this header.
$url = "http://www.test.de";
$input = file_get_contents($url) or die("Could not access file: $url");
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $input, $matches))
{
// $matches[2] = array of link addresses
// $matches[3] = array of link text - including HTML code
}