This script will detect URLs in a string and automatically create a link to this URL.
it removes the query-string and shows only the top-level of the site linked to as text.
“autolink” makes use of the built-in PHP functions preg_replace( ).
<?php
$txt = '
<p>
this is a string with
an url in it http://fundisom.com/g5/ and
its enough to be like that
</p>';
$txt = preg_replace('/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0">\4</a>', $txt);
echo $txt;
?>
this is a string with an url in it fundisom.com and its enough to be like that
it removes the query-string and shows only the top-level of the site linked to as text.
“autolink” makes use of the built-in PHP functions preg_replace( ).
<?php
$txt = '
<p>
this is a string with
an url in it http://fundisom.com/g5/ and
its enough to be like that
</p>';
$txt = preg_replace('/(http|ftp)+(s)?:(\/\/)((\w|\.)+)(\/)?(\S+)?/i', '<a href="\0">\4</a>', $txt);
echo $txt;
?>
this is a string with an url in it fundisom.com and its enough to be like that
0 comments:
Post a Comment