tags:

views:

133

answers:

1

Hi

I have some data (which users input using WYSIWYG editor). I have created a tool to create a csv copy of the data for some backup purposes. For each record I

$csv_data .= str_replace(
               array('<br />','<br/>', '\n', ','), 
               '', 
               strip_tags($db_data['description'])
              ).",";

for some of the records I find product description split across multiple lines, even though I am removing BR, new line characters etc above, and this breaks the csv file. Any idea what I am doing wrong? thank you very much for your help.

+3  A: 

You use '' around the \n. Single Quotes do not allow escape characters like \n, use double quotes ("") instead.

See:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single

dbemerlin
Brilliant .. i just couldnt spot it myself. Thanks