i've been looking all over for a script that will take a URL out of text and automaticly turn it into a link then print out the text
I was jsut looking at mine ( which works ) as compaired to the other ones i found ( which don't work 😛 ) and i realised that mine is VERY simple and straight forward, while thier had huge regex's and all that
So that got me wondeing... Will my code break?
take a look
<?
$post="this is a link to [url]www.vertigolabs.org[/url] i hope it works.";
$post_working=explode(" ",$post);
foreach ($post_working as $atom){
if(preg_match("/http:\/\//",$atom)){
$post_done.="<a href=\"$atom\" target=\"_blank\">$atom</a>";
}elseif(preg_match("/www./",$atom)){
$atom_fix.=preg_replace("/([ ]|^)[url]www./[/url]","http://www.",$atom);
$post_done.="<a href=\"$atom\" target=\"_blank\">$atom</a>";
}else{
$post_done.="$atom ";
}
}
return $post_done;
?>
Any input will help, thanks