php to display mysql output text as hyperlink

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Not sure if this goes to PHP or mySQL group (or both!).

I've got a home brewed blog started using PHP and mySQL to store and
display the entries/postings.

I've figured out that I could format the way the entries are displayed
from the database using nl2br2($string) to properly display paragraph

How can I parse the output and display a hyperlink one types in the
body of the entry, into an actual link.

If the body text looks like this for example:
Today I went to the zoo. If you want to visit the zoo, look at their
homepage at I think you'll like it a lot.

How can I get the output to be parsed, recogonize http:// or www. and
convet the plain text to an actual hyperlink?

Much thanks to those who can offer insight!!


Aside from the dull entry,

Re: php to display mysql output text as hyperlink


Quoted text here. Click to load it

Could be done with a regular expression, but it won't be reliable. Not
every URL starts with HTTP or a leading 'www'. What about using BBCode
or something like that?


Site Timeline