Page 1 of 1

wml <br /> and \n

Posted: Wed Mar 31, 2004 9:59 am
by swartbees
Hi there

I have a function which takes my wml string and converts all <br/> to \n:

function br2nl($string) {
$br = array('<br/>','<br />','<BR>','<BR/>','<BR />');
return str_replace($br,'\n',$string);
}

It seems to work fine when I do the following

$string = "This <br/> is my <br/> string";
echo br2nl($string);
//returns "This \n is my \n string"

When however I mail this string with phpmailer to a sms server the output that I get via sms is "This/n is my /n string".

I've tested:

$string = This \n is my \n string"

and it works fine. So somewhere in the string that my br2nl function returns thre must be special characters which mess up my mail. :evil:

Any suggestions on how to see what all the special characters are and how to remedy this?

Regards
swartbees

Posted: Wed Mar 31, 2004 10:07 am
by Steveo31
A stab in the dark, but what if you escape the \n like \\n?

Posted: Wed Mar 31, 2004 10:07 am
by swartbees
Tried that, but it doesn't work either :cry:

Posted: Wed Mar 31, 2004 11:47 am
by twigletmac
Put the \n in double quotes maybe, so "\n" in the str_replace() not '\n'?

Mac

Posted: Wed Mar 31, 2004 12:10 pm
by PrObLeM
why are you replacing <br/> with \n <br/> works just fine in wml

Posted: Wed Mar 31, 2004 12:11 pm
by swartbees
BRILLIANT! It works!

Thanx

Posted: Wed Mar 31, 2004 12:34 pm
by PrObLeM
....whos works...mine or twigletmac???