Hi Charles,

Not sure exactly what you are after, but....

function displayLinks ($pagecontents) {
        $search = '/<a (.*?)href="(.*?)"(.*?)<\/a>/im';
        $replace = '<a
$1href="recordstep.php?clientid=$clientid&testid=$testid&link=$2"$3</a>';
        return (preg_replace ($search, $replace, $pagecontents));
}

For me, that takes all the links in $pagecontents and modifies the links for
a recorder I am building. You could do something simular with it, although
if you need the name, you might want...

$search '/<a (.*?)href="(.*?)"(.*?)>(.*?)<\/a>/im';
And $4 would be your name.

I hope this helps.

Todd.


----- Original Message -----
From: "Charles Fowler" <[EMAIL PROTECTED]>
To: "Justin French" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, August 30, 2002 10:14 AM
Subject: Re: [PHP] How can I strip the code from HTML pages to extract
thecontents of a HTML page.


> I was looking into stripping HTML files that contain alot of links. I
> was trying to avoid the manual way of data entry. The contents i need
> are the name of the link (plain text which sits out side the HTML code)
> and all the a href tags. I would like the a href  (ie.the hyperlink)
> tags to be displayed on the HTML output as plain text. All other HTML
> tags would be kept in place.
>
> The reason why I am doing this is that I am placing a link's name and
> the http:// link in to flat files, where they can be updated just by
> appending to them. The srcipt that I have does the rest.
>
> I have looked into the functions suggested but do find the concepts and
> use of the opperators to strip the HTML involved esoteric and tricky.
>
> ¬¬Chuck¬¬
>
>


----------------------------------------------------------------------------
----


> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to