dimanche 22 février 2015

PHP: How to add newline characters to write on a file?

I'm creating a text string from a data-set and get the delimiter character for end of the line as an argument. When I write the string to file delimiter appear as text. If I directly append it to the string it get interpreted as escape character correctly. How can append the argument to be interpreted as escape sequence? See the output below.


Appended from argument:


$dataRecord .= $escape; HHHHHHHHHH 2015-02-22\n\r


Append as string:


$dataRecord .= "\n\r"; HHHHHHHHHH 2015-02-22 ^M


Aucun commentaire:

Enregistrer un commentaire