|
Posted by Jochem Maas on 08/24/05 16:44
Dotan Cohen wrote:
> I seem to be having trouble with \n and \r in variables. I write my
> code on a linux box, and the server is linux. So I should always have
you are mixing /n and \n etc etc - stop it :-)
\n is a new line in linux
\r is a new line in (older?) version of MacOS
\r\n is a new line in Windoze
try something along the lines of:
<?php
$string = "\nthis is a test\r\nthis is a test\rthis is a test\nthis is a test";
$finds = array("\n", "\r");
$repls = array(" ***\\n*** "," ***\\r*** ");
echo str_replace($finds, $repls, $string);
> \n\r, no? Is there a way the I could print $variable; and have it show
> me the /n and /r 's ? I tried with a srt_replace() on /n and on /r,
> but they do not get replaced. I also tried escaping the backslash,
> then double escaping that as was suggested somewhere in the
> php.net/manual, then triple escaping!
I get the impression you need to find out what the difference is between
single and double quotes strings and how escape sequences differ/behave
within them
>
> Thanks ahead of time for any insight.
outsight, downsight, upsight, insideoutsight, roundaboutsight ...
ignore me now - I'm feeling bored.
>
> Dotan Cohen
> http://lyricslist.com/lyrics/artist_albums/183/etheridge_melissa.php
> Etheridge,Melissa Song Lyrics
>
[Back to original message]
|