Code Comments
Programming Forum and web based access to our favorite programming groups.Nils Jansen wrote:
> as a result from the script that i'm searching for, i want to get the
> full
>
> <a href=http://www.blabla.com/test/d.html>DESCRIPTOIN</a>
>
> can anybody give me some hint, how to do this?
Try this (remark: array_combine is a PHP 5 specific function, see the manual
entry for this function on php.net for a PHP 4 example);
<?php
// Fetch the content
$file = file_get_contents("http://www.php.net/");
// Construct the regular expression
// (does not accept image links)
$reg = "#<a.*href\s*=\s*(\"|')?([^\"'>]+).*>([^<>]+)</a>#i";
// Parse $file
if (preg_match_all($reg, $file, $matches)) {
print "<pre>";
print_r(array_combine($matches[2], $matches[3]));
print "</pre>";
}
?>
HTH;
JW
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.