End of line evaluation within PHP/HTML

时间:2015-07-28 15:50:57

标签: php html csv end-of-line

I use a form which purpose is to generate a customized .csv file. Among other things, the user can specify the end of line character.

To do so, he simply enters it in a text area. I have a problem with the backslashed characters, and in particular "\n".

If I don't check the string, the "\n" entered by the user isn't evaluated. It is added to the .csv file as a string, and the outputed CSV has only one line with all the values...: value1\nvalue2\n instead of :

value 1
value 2
...

So far, I've found a way to deal with it, making the following test :

if ($var == '\n') {
$var = "\n";
}

Is there a more elegant way to solve this problem ?

0 个答案:

没有答案