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
______________________________
