Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
|
BBCode is probably done best with regular expressions.
This would be the RegEx to replace
[b ]*text*[ /b] with <b>*text*</b>:
PHP Code:
<?php
echo preg_replace(
"/\[b\](.*)\[\/b\]/", //RegEx Pattern, this looks really weird but that's because many characters need to be escaped
"<b>$1</b>", //Replacement, $1 stands for the first subpattern (which you can define in the pattern by: "(more pattern)"
"[b]*Text*[/b]"); //String to be processed
?>
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>
Last edited by Insensus; 10-27-2007 at 04:49 AM..
|