Thread: BB Code
View Single Post
Old 10-25-2007, 11:26 AM   #9 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've redone your regex and removed the preg_quote.

PHP Code:
function BBcode($szInput)
{
 
$aBBPattern = array(
                     
'\[b\](.*?)\[\/b\]' => '<b>\\1</b>',
                     
'\[i\](.*?)\[\/i\]' => '<i>\\1</i>',
                     
'\[url="([http:\/\/]+[^"]+)"\](.*)\[\/url\]' => '<a href="\\1">\\2</a>'
                     
);

 foreach( 
$aBBPattern as $szKey => $szValue )
 {
    
$szPattern '/'$szKey .'/isU';
    
$szInput    preg_replace$szPattern$szValue$szInput );
 }

 return 
$szInput;


__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote