Ask a Question related to PHP Development, Design and Development.
-
Nils Jansen #1
PHP: extract links AND description from html
extracting just the links from a webpage is no problem for me ->
regex /<a ([^>]*)>/i
but now i want to extract the link and the discription that stands between
the <a href=> and the </a> tag.
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?
Nils Jansen Guest
-
help data extract to text without html tag
Hi Ive a page as below and it will save the record to text, but it does not save the file as what I needed. when i open up the file it didplaay... -
HTML in service description
Hi I've documenten my webservice with html tags in the description. For a day ago this worked. Now suddenly all is treated as plain text and it... -
[PHP] Extract a little string from a Html page ?
I tried something else but... It doesn't work too :-( . <? php $fichier=implode('',array_map('trim',readfile("http://myurl.com"))); if (eregi... -
extract from html
hi, how can i extract the number between text1 and text2 in input.html only the first time it occurs ignoring the rest? preferably input.html... -
When we move Image Links and HTML links
On our Local Site (hard drive), our web projects is almost complete and we have already uploaded and sync the internet site (remote site). I have... -
Janwillem Borleffs #2
Re: extract links AND description from html
Nils Jansen wrote:
Try this (remark: array_combine is a PHP 5 specific function, see the manual> 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?
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
Janwillem Borleffs Guest



Reply With Quote

