01-08-2008, 08:09 PM
|
#25 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
|
I actually wrote a class for BB code, but I don't think Karl'd appreciate me handing it out, unfortunately. The following should give you a good idea. It does the bold, italic and underline for you:
PHP Code:
$szText = 'This is [u]a[/u] [b]test for bold[/b].';
$szText = preg_replace('~\[b\](.+?)\[/b\]~i', '<b>\\1</b>', $szText); $szText = preg_replace('~\[i\](.+?)\[/i\]~i', '<i>\\1</i>', $szText); $szText = preg_replace('~\[u\](.+?)\[/u\]~i', '<u>\\1</u>', $szText);
echo $szText;
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|