Hi guys,
Ive got a function which goes through a webpage and extracts all the links, ive got it to count the number of elements...but now want to iterate through each link to read the pages, can you help? Im not sure what the correct syntax is...
<?
function get_urls($string) {
$types = array("href");
while(list(,$type) = each($types)) {
preg_match_all ("|$type\=\"?'?`?([[:alnum:]:?=&@/._-]+)\"?'?`?|i", $string, &$matches);
$ret[$type] = $matches[1];
}
return count($ret[href]);
}
$homepage = 'http://www.example.co.uk';
$fp = fopen($homepage, 'r');
if(!$fp) {
echo "Unable to open\n";
} else {
while(!feof($fp)) {
$body = $body . fread($fp, 1024);
}
}
print_r(get_urls($body));
?>
Need to be able to extract each element so calling array[0] array[1] etc
Cheers for any help