how can i convert this bbcode [myURL]http://www.phpbuilder.com[/myURL]
to
<a href="http://www.phpbuilder.com">http://www.phpbuilder.com</a>
i saw lots of web forum using this format
Eheem.
www.phpclasses.com and search for BBcode.
www.scriptsearch.com and search for BBcode.
You may think that looking at other peoples work is bad, unethical or somming. But it is what other people do, and thats how word spreads 😉
[At least i hope this is right 😉]
thx for the reference but do you have any simple example ?
coz i need such BBcode stuff in my textarea.
what i need is just bold, italic, underline and url
i can figure out how to do bold, italic and underline.
but i have difficulty with url, since i need to get the text between [urI][/urI]
whoops, sorry 😐
$msg = eregi_replace("\[url\]www.([\[])\[/url\]", "<a href=\"http://www.\1\" target=blank>\1</a>",$msg); $msg = eregi_replace("\[url\]([^\[]*)\[/url\]","<a href=\"\1\" target=blank>\1</a>",$msg); $msg = eregi_replace("\)\]([^\[]*)\[/url\]", "<a href=\"http://www.\1\" target=blank>\1</a>",$msg); $msg = eregi_replace("\[url=([\[]*)\]([^\[]*)\[/url\]","<a href=\"\1\" target=blank>\2</a>",$msg);
Second example but using PERL-compatible regex :
$regex = "/\[url\]([^\[]*)\[\/url\]/U"; $url = preg_replace ($regex, "<a href=\"\\1\">\\1</a>", $url);
The URL can be made up by anything but [. However it avoids greediness using the U modifier.
Interesting URL I found : bbCode (Free - Duncan Mundell) : http://duncan.xtreme.net.nz/bbCode.php.txt
JM