Search code examples
phpfgetcsv

How to provide a string delimeter in fgetcsv()


Since my file columns are separated by a tab, I use the following:

while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {

But is there a way to deal with a string delimiter as well?

enter image description here


Solution

  • Add more one optional parameter:

    $data = fgetcsv($handle, 1000, "\t", "\"");
    

    Here more information about fgetcsv