Click to See Complete Forum and Search --> : Help stripping out BR in mailoutput


Siddan
01-03-2008, 04:13 PM
Hello I have this piece of code where it emails the information. On some values I may have a line break in them <br>. So I would like to have any BR stripped

// Mailbody
$subject = $mosConfig_sitename.': '.stripslashes($formtitle.' - '.$joomlauser);
$crlf = '<br />';
$hrline = '<hr>';
if ($row->html!='1'){
$crlf = "\n";
$hrline = "-----------------------------------------------";
}
$email_copy_header = ARTF_EMAILCOPYMAIL.$crlf.$crlf;
$body = stripslashes($formtitle.' - '.$joomlauser.'('.$joomlausername.')').$crlf;
$body .= $hrline.$crlf.$crlf;

if($mail_data){
foreach($mail_data as $data_name => $data){
$body .= $data_name.': ';
if(is_array($data)){
$body .= $crlf;
$d2 = '';
foreach($data as $d){
$d2 .= $d;
}
$data = $d2;
}
$body .= $data.$crlf;
}
}
$body .= $hrline.$crlf; // lägga till linje här istället
$body .= ARTF_JUSER.': '.$joomlauser.$crlf;
$body .= ARTF_JUSERNAME.': '.$joomlausername.$crlf;
$body .= ARTF_JUSERIP.': '.$joomlauserip.$crlf;
$body .= $hrline.$crlf;
// End Mailbody

Hope anyone can give a helping hand

NogDog
01-03-2008, 08:16 PM
One option (replaces <br> tags with a newline, change the "\n" to " " if you want a space, instead, or just "" if you want to replace it with nothing):

$text = preg_replace('#<br\s*/?>#i', "\n", $text);

Siddan
01-03-2008, 11:32 PM
Yes YES Thank you!

Very much delighted after a long time trying to figure this out