Page 1 of 1

csv file - field contents appear on multiple lines

Posted: Sun Jun 20, 2010 5:47 pm
by vcarter
I'm trying to build a csv file from a database (and other static information) using php -- one of the fields, however, contains html -- this was intended.

When I load this field into the csv file, it returns the results on multiple lines. ie:

Instead of this:

<li>Item one</li><li>Item two</li>

It does this:

<li>Item one</li>
<li>Item two</li>

And, the purpose of the csv file is to use as an imported file for a specific program, but it doesn't work if the field's contents are on multiple lines.

How can I get it to all be on one line? I've tried replacing "\n" with a space, but that doesn't work.

TIA.

Re: csv file - field contents appear on multiple lines

Posted: Sun Jun 20, 2010 7:51 pm
by vcarter
Just for clarification -- this is not a question about the csv file -- my question pertains to a php command I can use that will remove whatever is causing the text in that field to appear on multiple lines instead of in one single line.

Thanks :)

Re: csv file - field contents appear on multiple lines

Posted: Sun Jun 20, 2010 7:55 pm
by McInfo
Try replacing \r\n with a space.

Or, with preg_replace(), replace characters matched by \v (any vertical whitespace character).

Re: csv file - field contents appear on multiple lines

Posted: Sun Jun 20, 2010 8:18 pm
by vcarter
THANK YOU!

Replacing \r\n did it.