I have a MySQL database for an online shopping cart. I am attempting to put some of the information from the cart into a CSV file for another use but I am having a strange problem. Each product has a description and a few of those have a carriage returns in them usually theres an html <p> or <br> there also. Now I can strip out the html tags but that has no effect on the problem. What looks to be happening is that each carriage returns that's in the descriptions it for some reason is causing a new line in the CSV file. I am assuming there is a "\r" or "\n" that I am not seeing. How would I strip those out so each descritpion is in one line of my CSV file. Keep in mind that at present I am also striping out html tags and haveing to change single and doulble quotes in the description also so they don't cause any problems.
I would have to assume that this post got overlooked. There has to be a solution.
This is probably some unoptimized regexp, but....
$no_linebreaks = ereg_replace("\n\r|\r|\n", '', $data)
Before reaplcing all the HTML, run nl2br (Which converts new lines into a <br>. Then strip it out.
Or you could try wether it is recognized by str_replace..
J.
You know, I had never tested that function to see if it incorporates the 3 types of line breaks.. and apparently it does!
Heh, my bad 😉