-3

Possible Duplicate:
php html create link from text

How can i convert written urls within text posted by user in textarea into clickable links using php ?

Community
  • 1
  • 1
wfareed
  • 139
  • 2
  • 17

2 Answers2

1

distinguish your link from the regular text by wrapping it. like [link]http://example.be[/link]

Then parse the text with php and transform the [link] tags into html link tags

or use a regular expression to detect urls in your text.

If you want more specific answers, you should make more work of your questions. Please read the stackoverflow faq for more info.

Community
  • 1
  • 1
jan
  • 2,879
  • 2
  • 19
  • 28
0

you could use php's preg_replace function

 <?
    $string = "[url]http://stackoverflow.com[/url]";
    $search = array("/\[url]([^'\"]*)\[\/url]/iU");
    $replace = array("<a href=\"\\1\" target=\"_blank\">\\1</a>");
    echo preg_replace($search, $replace, $string);
 ?>
Liam Allan
  • 1,115
  • 1
  • 8
  • 13