Sin librerías:
Código (php) [Seleccionar]
<?php
$buffer = file_get_contents('http://foro.elhacker.net/');
$links = explode('<a', $buffer);
array_shift($links);
foreach($links as $id => $link){
$lnk = explode('href="', $link);
$lnk = explode('"', $lnk[1]);
$lnk = $lnk[0];
$text = explode('>', $link);
$text = explode('<', $text[1]);
$text = $text[0];
if(substr(trim($text), 0, 1) == '<')
$type = 'object';
elseif(!trim($text))
$type = 'bad link';
else
$type = 'text';
$ob_links[] = array(
'id' => ($id + 1),
'link' => $lnk,
'text' => $text,
'type' => $type
);
}
print_r($ob_links);
?>