The string input comes from textarea where users are supposed to enter every single item on a new line.
When processing the form, it is easy to explode the textarea input into an array of single items like this:
$arr = explode("\n", $textareaInput);
It works fine but I am worried about it not working correctly in different systems (I can currently only test in Windows). I know newlines are represented as \r\n
or as just \r
across different platforms. Will the above line of code also work correctly under Linux, Solaris, BSD or other OS?
[\r\n]
means either\r
or\n
. It looks for any combination of the two characters... And no, you are incorrect. I do in fact prefer working on Linux, and I am well aware of the differences. – Ebonieebonite