str_replace help

------_=_NextPart_001_01CAD268.68B490D1
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hi folks,

In ASP, I would commonly replace string line feeds for HTML output like
this:

Var =3D replace(value,vbcrlf,"<br>")

In PHP, the following doesn't seem to work:
$var =3D str_replace(chr(13),"\n",$value)

Neither does:
$var =3D str_replace(chr(10),"\n",$value)

What am I doing wrong?

Thanks!

------_=_NextPart_001_01CAD268.68B490D1--
David Stoltz [ Fr, 02 April 2010 15:28 ] [ ID #2037562 ]

Re: str_replace help

--=-An5zSlxrKKt8lBd16eMF
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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



--=-An5zSlxrKKt8lBd16eMF--
Ashley Sheridan [ Fr, 02 April 2010 15:33 ] [ ID #2037563 ]

Re: str_replace help

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
मेरा भारत महान !
मम भारत: महत्तम भवतु !

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Nilesh Govindrajan [ Fr, 02 April 2010 17:22 ] [ ID #2037625 ]

SimpleXMLElement and gb2312 or big5

I use the following code to get rss and parse it, but the code
occasionally have issues with gb2312 or big-5 encoded feeds, and fails to
parse them. However other times may appear just okay. Any thoughts? Maybe
SimpleXMLElement is simply not meant for other language encodings...

$page = file_get_contents($rss);
try {
$feed = new SimpleXMLElement($page);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Peter Pei [ Fr, 02 April 2010 16:48 ] [ ID #2037626 ]
PHP » gmane.comp.php.general » str_replace help

Vorheriges Thema: preg_match? Or something else?
Nächstes Thema: How to know which PHP is used by Apache