Prev: Apache rule/directive to stop serving PHP pages from /var/www/includes/ [SOLVED]
Next: SimpleXMLElement and gb2312 or big5
From: "David Stoltz" on 2 Apr 2010 09:28 Hi folks, In ASP, I would commonly replace string line feeds for HTML output like this: Var = replace(value,vbcrlf,"<br>") In PHP, the following doesn't seem to work: $var = str_replace(chr(13),"\n",$value) Neither does: $var = str_replace(chr(10),"\n",$value) What am I doing wrong? Thanks!
From: Ashley Sheridan on 2 Apr 2010 09:33 On Fri, 2010-04-02 at 09:28 -0400, David Stoltz wrote: > Hi folks, > > In ASP, I would commonly replace string line feeds for HTML output like > this: > > Var = replace(value,vbcrlf,"<br>") > > In PHP, the following doesn't seem to work: > $var = str_replace(chr(13),"\n",$value) > > Neither does: > $var = str_replace(chr(10),"\n",$value) > > What am I doing wrong? > > Thanks! I see no reason why it shouldn't work other than maybe the string doesn't contain what you think it does. Thanks, Ash http://www.ashleysheridan.co.uk
From: Midhun Girish on 2 Apr 2010 09:47 well david actually $var = str_replace(chr(13),"\n",$value) will replace char(13) with \n... but \n wont come up in html unless u give a <pre> tag.. u need to put $var = str_replace(chr(13),"<br/>",$value) in order to got the required output.... Midhun Girish On Fri, Apr 2, 2010 at 7:03 PM, Ashley Sheridan <ash(a)ashleysheridan.co.uk>wrote: > On Fri, 2010-04-02 at 09:28 -0400, David Stoltz wrote: > > > Hi folks, > > > > In ASP, I would commonly replace string line feeds for HTML output like > > this: > > > > Var = replace(value,vbcrlf,"<br>") > > > > In PHP, the following doesn't seem to work: > > $var = str_replace(chr(13),"\n",$value) > > > > Neither does: > > $var = str_replace(chr(10),"\n",$value) > > > > What am I doing wrong? > > > > Thanks! > > > I see no reason why it shouldn't work other than maybe the string > doesn't contain what you think it does. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > >
From: Nilesh Govindarajan on 2 Apr 2010 11:22
On 04/02/10 18:58, David Stoltz wrote: > Hi folks, > > In ASP, I would commonly replace string line feeds for HTML output like > this: > > Var = replace(value,vbcrlf,"<br>") > > In PHP, the following doesn't seem to work: > $var = str_replace(chr(13),"\n",$value) > > Neither does: > $var = str_replace(chr(10),"\n",$value) > > What am I doing wrong? > > Thanks! > Use nl2br. -- Nilesh Govindarajan Site & Server Administrator www.itech7.com मेरा भारत महान ! मम भारत: महत्तम भवतु ! |