February 2013
Intermediate to advanced
538 pages
20h 55m
English
fgetcsv
array fgetcsv(resourcehandle[, intlength[, stringdelimiter[, stringenclosure[, stringescape]]]])
Reads the next line from the file referenced by
handle and parses the line as a
comma-separated values (CSV) line. The longest line to read is given
by length. If
delimiter is supplied, it is used to
delimit the values for the line instead of commas. If supplied,
enclosure is a single character that is
used to enclose values (by default, the double quote character
").
escape sets the escape character to use;
the default is backslash \; one
character only can be specified. For example, to read and display all
lines from a file containing tab-separated values, use:
$fp=fopen("somefile.tab","r");while($line=fgetcsv($fp,1024,"\t")){"<p>".count($line)."fields:</p>";print_r($line);}fclose($fp);
Read now
Unlock full access