Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006
    Posts
    39
    Plugin Contributions
    0

    Default 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 inform######## 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

  2. #2
    Join Date
    Nov 2006
    Location
    Papworth, Cambridgeshire, UK
    Posts
    725
    Plugin Contributions
    3

    Default 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

  3. #3
    Join Date
    Nov 2006
    Posts
    39
    Plugin Contributions
    0

    Default 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!?

  4. #4
    Join Date
    Nov 2006
    Location
    Papworth, Cambridgeshire, UK
    Posts
    725
    Plugin Contributions
    3

    Default 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,

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •