Im want to make the bbcode. I found this small tutorial and its understandable.
It parses only "url" and "b".. I want to add more things also, for instance [I ][ /I] and [U ][/U ]. can someone help me to extend this code? I tried to do by myself and couldnt get success.
Thanks.
<?php $string = 'This is [b]cool[/b] - [url=http://www.yahoo.com]Yahoo website.[/url] '; $bb_replace = array ( '/(\[[Bb]\])(.+)(\[\/[Bb]\])/', '/(\[url=)(.+)(\])(.+)(\[\/url\])/' ); $bb_replacements = array ( '<b>\\2</b>', '<a href="\\2">\\4</a>' ); $string = preg_replace($bb_replace, $bb_replacements, $string); print $string; ?>
