★ wanayoo — archive 1999 http://uk.php.net/manual/en/function.fgetcsv.phpNouvelle recherche | Portail wanayoo
PHP Tuesday, March 20, 2001  
downloads | documentation | faq | support | reporting bugs | links 

search for in the  

lookup:
PHP ManualPHP Manual
FilesystemFilesystem
 basenamebasename
 chgrpchgrp
 chmodchmod
 chownchown
 clearstatcacheclearstatcache
 copycopy
 deletedelete
 dirnamedirname
 diskfreespacediskfreespace
 fclosefclose
 feoffeof
 fflushfflush
 fgetcfgetc
 fgetcsvfgetcsv
 fgetsfgets
 fgetssfgetss
 filefile
 file_existsfile_exists
 fileatimefileatime
 filectimefilectime
 filegroupfilegroup
 fileinodefileinode
 filemtimefilemtime
 fileownerfileowner
 filepermsfileperms
 filesizefilesize
 filetypefiletype
 flockflock
 fopenfopen
 fpassthrufpassthru
 fputsfputs
 freadfread
 fscanffscanf
 fseekfseek
 fstatfstat
 ftellftell
 ftruncateftruncate
 fwritefwrite
 set_file_bufferset_file_buffer
 is_diris_dir
 is_executableis_executable
 is_fileis_file
 is_linkis_link
 is_readableis_readable
 is_writableis_writable
 is_writeableis_writeable
 is_uploaded_fileis_uploaded_file
 linklink
 linkinfolinkinfo
 mkdirmkdir
 move_uploaded_filemove_uploaded_file
 pclosepclose
 popenpopen
 readfilereadfile
 readlinkreadlink
 renamerename
 rewindrewind
 rmdirrmdir
 statstat
 lstatlstat
 realpathrealpath
 symlinksymlink
 tempnamtempnam
 tmpfiletmpfile
 touchtouch
 umaskumask
 unlinkunlink

previousfgetc
fgetsnext

Last updated: Mon, 19 Mar 2001
view this page in English | Brazilian Portuguese | Czech | Dutch | French | German | Hungarian | Italian | Japanese | Korean | Spanish | Plain HTML

fgetcsv

(PHP 3>= 3.0.8, PHP 4 )

fgetcsv --  Gets line from file pointer and parse for CSV fields

Description

array fgetcsv (int fp, int length [, string delimiter])

Similar to fgets() except that fgetcsv() parses the line it reads for fields in CSV format and returns an array containing the fields read. The field delimiter is a comma, unless you specify another delimiter with the optional third parameter.

Fp must be a valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen()

Length must be greater than the longest line to be found in the CSV file (allowing for trailing line-end characters).

Fgetcsv() returns false on error, including end of file.

N.B. A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.

Example 1. Fgetcsv() example - Read and print entire contents of a CSV file


$row = 1;
$fp = fopen ("test.csv","r");
while ($data = fgetcsv ($fp, 1000, ",")) {
    $num = count ($data);
    print "<p> $num fields in line $row: <br>";
    $row++;
    for ($c=0; $c<$num; $c++) {
        print $data[$c] . "<br>";
    }
}
fclose ($fp);
     
previousfgetc
fgetsnext

Last updated: Mon, 19 Mar 2001
add note | about notes

show source | credits | mirror sites:  

Copyright © 1998-2001 The PHP Group
All rights reserved.
This mirror generously provided by: Norwich
Last updated: Tue Mar 20 06:25:02 2001 GMT