Sometimes, there are just weird things with line breaks — it’s really hard to tell what type of line break is embedded in certain data. Sometimes, text entered from a form with line breaks throws the output off, especially if your script needs to break the text or often the data feed down by line (also referred to as a row).
If you can capture the text in the $text variable, this will output it and find those line break offenders. Throw Mac keyboard input into the mix, and you can spend hours trying to find these things so your script reads and breaks up the data properly.
echo str_replace(array('\r\n', '\r', '\n', '\t'), array('\\r\\n', '\\r', '\\n', '\\t'), $text);