Link:
-------------------------------------------
<?php
$str = str_replace("&", "&", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace("\t", " ", $str);
$str = str_replace("\r", "", $str);
$str = str_replace("\n", "<br>", $str);
$str = eregi_replace("(( |\n|\r)((f|ht)tp://)([a-z0-9@:%_.~#\-\?&-]+)((\=|[a-z0-9]|\?|&|\/|\.|-|:|æ|ø|å)+){0,})", " <a href='\\1' target='_blank' class='main'>\\1</a>", $str);
$str = eregi_replace("([ |\n|\r](www)([a-z0-9@:%_.~#\-\?&-]+)((\=|[a-z0-9]|\?|&|\/|\.|-|:|æ|ø|å)+){0,})", " <a href='
http://\\1' target='_blank' class='main'>\\1</a>", $str);
$str = ereg_replace("\[link=http://([^]]+)\]", "<a href='
http://\\1' target='_blank' class='main'>", $str);
$str = ereg_replace("\[link=www([^]]+)\]", "<a href='
http://www\\1' target='_blank' class='main'>", $str);
$str = ereg_replace("\[/link\]", "</a>", $str);
?>
-----------------------------------------------
Så kan du skrive [link]www.dr.dk[/link], [link=www.dr.dk]Klik her for at åbne DR's hjemmeside[/link]
Regins burde virke med denne rettelse:
-----------------------------------------
<?php
$str = "fdsajl fsdajlk fds
ajlæk s[/b]f
adl fsdajlk fds
ajlæk s[/b]f
ad";
$pattern = '/(\[b\])((.|\n)*?)(\[\/b\])/';
$replace = '<b>\\2</b>';
echo $str."</br>";
$str = preg_replace($pattern, $replace, $str);
$str = str_replace("[b]","",$str);
$str = str_replace("","",$str);
echo $str;
?>