php - Use array of delimiters -


i'm using fgetcsv read csv files in application. problem don't know if users use ,, |, or ; delimiters. if tell fgetcsv nothing accept , if tell use specific delimiter accept that.

what i'm doing is:

while (($row = fgetcsv($filehandle, 4096)) !== false) {  

what want this:

while (($row = fgetcsv($filehandle, 4096, array(',', ';', '|'))) !== false) { 

is possible in easy way? seems weird have limit delimiter 1 specific character, since csv not standardized.

you cannot reliably determine delimiter of csv file if don't know it. take simple example:

foo;bar,hello;world 

what delimiter? , or ;? if pass array array(',',';') data expecting fgetcsv() return?

if don't know delimiter need ask user it.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -