Topic: remove bbcode on the email

Hi,

Perhaps something to do, oneday..., when you have time, .... I'm not 100% sure ...

It could be good to remove bbcode inside the message send by email. because is not really readable.
In an other hand keep [ code ] and [ quote ] could be usefull, is why I'm not 100% sure if my request is relevant or not ....

2 (edited by tuyau45 2005-04-12 21:42)

Re: remove bbcode on the email

Hi again,

I try to do something :

// clean off the message of all BBcode 
$a = array('[ b ]', '[ i ]', '[ u ]', '[ /b ]', '[ / i]', '[ /u ]', '[ url ]', '[ /url ]', '[ email ]', '[ /email ]', '[ img ]', '[ /img ]');
$message = str_replace($a, '', $message);
                
$a = array('[ quote ]', '[ code ]', '[ /quote ]', '[ /code ]');
$message = str_replace($a, '\r\n------------\r\n', $message);
                
$a = array( '#\[url=("|\'|)(.*?)\\1\]\s*#i', '#\[email=("|\'|)(.*?)\\1\]\s*#i', '#\[colou?r=("|\'|)(.*?)\\1\](.*?)\[/colou?r\]#is','#\[quote=("|\'|)(.*?)\\1\]\s*#i');
$b = array( '$2', '$2', '$3', '$2 écrit : \r\n------------\r\n');
$message = preg_replace($a, $b, $message);

It's work except for

\r\n------------\r\n

it give me back \r\n------------\r\n

and I want

"go to the next line"
------------
"go to the next line"

How i can manage that ?

Re: remove bbcode on the email

'\r\n------------\r\n' must be "\r\n------------\r\n"

\n \t need " not '

Re: remove bbcode on the email

Tx  Connorhd !!!

my final code to insert in post.php after

$mail_message_full = str_replace('<replier>', $username, $mail_message_full);

remove the space betwenn [ ]

// clean off the message of all BBcode
$a = array('[ b ]', '[ i ]', '[ u ]', '[ /b ]', '[ /i ]', '[ /u ]', '[ url ]', '[ /url ]', '[ email ]', '[ /email ]', '[ img ]', '[ /img ]');
$message = str_replace($a, '', $message);
                
$a = array('[ quote ]', '[ code ]');
$b = array("\n\n------------------------\n\tQuote :\n\n", "\n\n------------------------\n\tCode :\n\n");
$message = str_replace($a, $b, $message);
                
$a = array('[ /quote ]', '[ /code ]');
$message = str_replace($a, "\n\n------------------------\n\n", $message);
                
$a = array( '#\[url=("|\'|)(.*?)\\1\]\s*#i', '#\[email=("|\'|)(.*?)\\1\]\s*#i', '#\[colou?r=("|\'|)(.*?)\\1\](.*?)\[/colou?r\]#is','#\[quote=("|\'|)(.*?)\\1\]\s*#i');
$b = array( "$2", "$2", "$3", "\n\n------------------------\n\t$2 write :\n\n");
$message = preg_replace($a, $b, $message);