Converting Text to Hyperlinks
| From: | Alexis Antonakis | Date: | Wed, 29 May 2002 03:28:54 +0000 |
| Subject: | Converting Text to Hyperlinks | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-99613@lists.php.net to get a copy of this message | ||
Hi All,
I am designing a News board and wish to convert any text beginning with
'http://' into a hyperlink, when displayed on the page.
I have converted all the HTML tags (htmlspecialchars) before saving the
data.
I can do the initial bit fine (adding the <a href=...>) before the start of
the link, but I am having great difficulty in adding the closing tag.
The main problems I am having are:
i) If there is more than one link.
ii) If the User has entered the link with the correct HTML in the first
place, I just want to convert it back into HTML (Obviously they would need
to have entered the 'http://' part of it.
iii) If there is a line break at the end of the link, opposed to a space. I
am presuming that there are no spaces in the link for this one.
I have been going round in circles for quite a few hours now, but just don't
seem to be progressing, so any help anyone can offer will be very much
appreciated.
Regards
Alexis