CSV - Sentences with comma's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

CSV - Sentences with comma's

Post by facets »

Hi All,

I'm trying to export a CVS and have coem across a glitch.
The user has used comma's in a sentence and it has been saved into the DB.

When I export as CSV the comma triggers evrything after it to move one space left.
(Obviously how it should work!)

How would encapsulate the comma in the sentence and avoid excel/OOffice from using it?

Here's how i'm creating the code :

Code: Select all

echo "$colloPaperName,", "$paperCategory\n";
Tks, Will.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Place the sentance in quotes?
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

So simple.
I was unaware that the quotes don't display in the csv.

Cheers!
Post Reply