te recomiendo que lo hagas de esta forma ..
Código PHP:
<?
$url="http://www.forosdelweb.com";
$contenido = file_get_contents($url) ;
$links = buscar_link($contenido);
function buscar_link($string){
$patron = "/(<a href=\")(.+?)(\")(\s*)(>)(.+?)(<\/a>)/sie";
preg_match_all($patron, $string, $matches);
return $matches[0];
}
echo "<pre>";
print_r($links);
echo "</pre>";
?>
este ejemplo te devuelve lo siguiente
Código HTML:
<pre>Array
(
[0] => <a href="index.php?"><img src="/images/vbulletin3_logo_fdw.gif" border="0" alt="Foros del Web es una comunidad de ayuda al webmaster hispano" width="207" height="108" /></a>
[1] => <a href="http://www.maestrosdelweb.com/" target="_blank" title="Visitar el sitio de Maestros del Web">Maestros del Web</a>
[2] => <a href="http://www.faqsdelweb.com/" target="_blank" title="Visitar el sitio de Faqs del Web">Faqs del Web</a>
[3] => <a href="http://www.desarrolloweb.com/" target="_blank" title="Visitar el sitio de Desarrollo Web">Desarrollo web</a>
[4] => <a href="http://maestrosdelweb.mercadoprofesional.com/" target="_blank" title="Visitar el sitio de Desarrollo Web">Mercado Profesional</a>
[5] => <a href="index.php?" accesskey="1"><img class="inlineimg" src="/images/misc/navbits_start.gif" alt="" border="0" /></a>
[6] => <a href="register.php?" rel="nofollow">Registrarse</a>
[7] => <a href="faq.php?" accesskey="5">FAQ</a>
)
</pre>
solo mostre parte del array, ya que, son muchos elementos ...
esto complementa a lo que te respondi en
http://www.forosdelweb.com/f18/extraer-parte-exacta-cadena-con-etiquetas-344805/