tags:

views:

184

answers:

2

Is it possible to use fgetcsv in PHP to open a tab-delimited file?

+1  A: 

yes, you can specify tab "\t" in its parameters. see the doc.

while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE)
ghostdog74
+2  A: 
$csvData = fgetcsv($fileHandle, 0, "\t");

Where $fileHandle is a valid file handle. The 0 is just to tell the function not to limit seeking through lines (however you can change this to suit, the docs do say not imposing a limit decreases performance).

alex
is the tab delimiter different for macs?
Brian
@Brian I've had a quick Google, and I don't think so. Usually that's just line endings and line feeds.
alex