Re: Help Needed with CSV & PHP

From: Date: Thu, 06 Jul 2000 01:10:16 +0000
Subject: Re: Help Needed with CSV & PHP
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-5132@lists.php.net to get a copy of this message
> Chris Adams wrote: > > > I was going to try to switch over to using Comma Seperated Values (CSV) > > > in PHP, with something like this: > > > while ($dataarray[$viewcard-1] = fgetcsv($dataarray[$viewcard-1],4000, > > > ":")) { > > > > http://gateway.digitaria.com/~chris/php/csv2table/csv2table.php has > > some > > generic code for displaying CSV as an HTML table. In CSV it's more or less > > accepted that data containing commas should be enclosed in quotes (quotes in > > data are escaped as \"). > > But if you are using CSV to seperate user input, you can't just tell > folks to enclose commas in quotes... No. In the case of the code above, unescaped commas would just add another column. Since there's no realistic way to tell whether a comma is data or formatting, the real question is whether it's acceptable to return an error or a "If it breaks, don't do that" message. Otherwise you're going to need to use something like multiple text inputs instead.

« previous php.general (#5132) next »