Jump to content

Archived

This topic is now archived and is closed to further replies.

matfish

Creaking a ahref link

Recommended Posts

Hi, hard to explain and not sure if its simply possible..

Say iv got a text feild in the database and im pulling it in so it looks like an article. If someone types in a URL like "This is an www.example.com" how can I make the URL clickable link in the article without them knowing the html tags etc..? I dont want them entering <a href= etc..

Thanks



Share this post


Link to post
Share on other sites
yes it can be done
using ereg_replace
<?php
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
                    "<a href=\"\\0\">\\0</a>", $text);
?>

Share this post


Link to post
Share on other sites
Sorry - dont understand?

Tried it and it didnt make any difference...

Thanks

Share this post


Link to post
Share on other sites
using the ereg_replace, it will find www.example.com, and replace it with <a hreg='www.example.com'>www.example.com</a>
not that it should be < / a > not [/url]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.