views:

32

answers:

3

I have a php data migration script that serializes an array of text. Somehow, and this is not in my codebase, but the script is inserting \\\\\\\r\\\\\\\n into the string. Here is an example of what the output is like:

Product Line: [56313] LEGO Batman Screenshot\\\\\\\\r\\\\\\\\n[5 6384] LEGO Batman Screenshot[56446] LEGO Batman Screenshot[56460] LEGO Batman: T

There are no line breaks in between the different products (as you can see, there are two products being shown there - that's two iterations). When the second product gets appended to the first, the \\\\\\r\\\\\\n gets prepended. This question is fairly difficult to explain, and I don't really think that any code will help explain it. What is this and how do I get rid of it? I'm on a windows platform.

+1  A: 

You can call trim(), http://us.php.net/trim

Mr-sk
A: 

Hard to tell what's going on without the code, but I would search the code for \r and \n and try and find out where this is being inserted.

Mike Weller
A: 

There are various ways to trim that string back to normal, but I suggest you search for the cause of why this happens.

The many backslashes look like the result of a (multiply) botched addslashes() operation, or a string being mangled by magic_quotes_gpc. The data definitely started with a line break somewhere along the line - if you got the data from a text file, presumably from there. These are two separate issues, even if you manage to remove the newlines, the slashes issue remains.

You would have to show us more code, or examine it using test output or a debugger.

Pekka