Forums / General Questions / Stripping newlines and carriage returns.

Stripping newlines and carriage returns.

Locked

Started by crin on 1 Oct 2007, 12:41 PM · Views: 929

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
1 Oct 2007, 12:41 PM
#1
crin avatar

crin

New Zenner

Join Date:
Nov 2006
Posts:
39
Plugin Contributions:
0

Stripping newlines and carriage returns.

Hi,

I have written a script that exports the contents of the products databes and write a tab delimted text file with results. This is used for importing the informaion in Gemm (www.gemm.com)

This all works fine until the script encounters a listing with carriage returns in the comments at which point this is output to the tab delimited text and is interpreted as a new row.

I have tried to strip these using...

$products_description = str_replace("/n", " ", $products_description);
$products_description = str_replace("/r", " ", $products_description);

before echoing the $products_description into the text file but it doesn't seem to be working.

Does Zencart store carriage returns inputted in the admin interface as something else?

Many Thanks.

Crin

1 Oct 2007, 1:48 PM
#2
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Location:
Papworth, Cambridgeshire, UK
Posts:
717
Plugin Contributions:
0

Re: Stripping newlines and carriage returns.

No, it stores them as carriage returns. You however are trying to replace something else. Carriage returns and linefeeds are denoted by backslashes? "\r" "\n" would probably be more effective

1 Oct 2007, 1:55 PM
#3
crin avatar

crin

New Zenner

Join Date:
Nov 2006
Posts:
39
Plugin Contributions:
0

Re: Stripping newlines and carriage returns.

HA HA HA HA HA HA!

Omg that was stupid. Thanks, sometimes it takes a fresh set of eyes huh!?

1 Oct 2007, 2:00 PM
#4
chuckl avatar

chuckl

Totally Zenned

Join Date:
Nov 2006
Location:
Papworth, Cambridgeshire, UK
Posts:
717
Plugin Contributions:
0

Re: Stripping newlines and carriage returns.

We all do it all the time. Those are usually the most difficult errors to find, because we don't read what is actually there. We "know" what is there.

Rgds,