Re: help with \n\r in strings



Don't fight it, just use this:

$dateAmount= preg_replace("%(\r\n|\r)%, "\n", $dateAmount);

This says: If the newline code ends with "\r\n" [ms] or "\r" [mac] replace it with "\n" [Apache]

Al...........



Angelo Zanetti wrote:
Hi all,

I receive a text file with a whole bunch of strings. and each line is terminated by what I presume is \n\r however when I read the string into PHP, it seems that the last column of the row and the first column of the next row are connected but it appears as a space but I've done all kinds of tests like $spacePos = strrpos($dateAmount, ' '); but this is always empty.

So is there a way to test for \r\n? or what else can I use to delimit these two values (last column of row and first column of next row)?

Thanks in advance.

Angelo
.



Relevant Pages

  • Re: Two results of set geometry
    ... The complete first column is not an *element* of Omega. ... The initial segments of the diagonal are projections of the initial ... segments of the first column including the whole infinite column. ... So let's talk about the strings of the symbol "1" in the system ...
    (sci.math)
  • help with in strings
    ... I receive a text file with a whole bunch of strings. ... and each line is terminated by what I presume is \n\r however when I read the string into PHP, it seems that the last column of the row and the first column of the next row are connected but it appears as a space but I've done all ... or what else can I use to delimit these two values (last column of row and first column of next row)? ...
    (php.general)
  • Re: [PHP] help with in strings
    ... I receive a text file with a whole bunch of strings. ... these two values (last column of row and first column of next row)? ... strpos($dateAmount, "\n") ... scalable system for accessing system services | ...
    (php.general)
  • Re: Two results of set geometry
    ... The complete first column is not an *element* of Omega. ... The initial segments of the diagonal are projections of the initial ... segments of the first column including the whole infinite column. ... So let's talk about the strings of the symbol "1" in the system ...
    (sci.math)
  • Re: Problems with textread and date formats
    ... > My idea was to read in the first column as a string and to then ... The help info for the %s format specifier states that it reads ... Since your time strings contain ... textread thinks is whitespace. ...
    (comp.soft-sys.matlab)