1.805 views
Hoe kan ik als ik tekst uit een database haal van de links (bijv: www.google.nl), dat het ook daadwerkelijk een klikbare link word. Alvast bedankt! :)
echo '<a href="'.$row['link'].'">'.$row['text'].'</a>';
function clickable($url){
$url = str_replace("\\r","\r",$url);
$url = str_replace("\\n","\n<BR>",$url);
$url = str_replace("\\n\\r","\n\r",$url);
$in=array(
'`((?:https?|ftp)://\S+[[:alnum:]]/?)`si',
'`((?<!//)(www\.\S+[[:alnum:]]/?))`si'
);
$out=array(
'<a href="$1" rel=nofollow>$1</a> ',
'<a href="http://$1" rel=\'nofollow\'>$1</a>'
);
return preg_replace($in,$out,$url);
}