fgetcsv

fgetcsv

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

fgetcsv which is used to get lines form the file pointer and parse for CSV field .

which gets a line which pointed by the file pointer and parse for CSV fields
in the line and the delimiter for CSV is optional by default its ‘,’ .
The length must me larger then line length.

take an example file: ab.txt

content of ab.txt
——————–
1,fname lname,description
2,fname2 lname2,description2

$row = 1;
$fp = fopen (”ab.txt”,”r”);
while (list($no,$name,$desc)= fgetcsv ($fp, 1000, “,”)) {
echo “serial no: $no \n”;
echo “Name : $name \n”;
echo “description : $desc \n”;
ehco “


“;
}

fclose ($fp);

Output will be:

serial no: 1
Name : fname lname
description : description
______________________________

serial no: 2
Name : fname2 lname2
description : description2
______________________________

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.