So ? Someone have another solution ?
PS: I forget ";" at the end of the first line, and "$" for "$pos2" in line four, now fixed here, try again.
PHP Code:
$text = "all the text here, go to http://someurl/thefile.php ok."; $pos1=strpos($text, "http://" ); $pos2=strpos($text, " ", $pos1) ; $link = substr($text, $pos1, $pos2-$pos1) ; $newtext = str_replace($link,'<a href="' . $link . '>' . $link . '</a>', $text ); echo $newtext ;
This will works for the first url, if it's ok, I will make it do so for all urls in the text..
Quote:
|
and of course it will "break" if the filename / url has spaces in it.
|
Spaces in urls are always replaces with %20 ( or something like that)
http://www.google.com/file1.html
http://www.google.com/file 1.html
Like in this forum, " it will "break" if the filename / url has spaces in it. "
Last edited by Ilyes; 09-08-2008 at 01:18 PM..
|