I am trying to parse a csv file using this code
if (($handle = fopen($csvFilePath, "r")) !== FALSE) {
$c=0;
$string="";
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($c>0)
{
if(($data[$email]!="") and ($data[$firstname]!="") and ($data[$lastname]!=""))
{
$string.='(1,';
$string.="'".$data[$email]."',";
$string.="'".$data[$firstname]."',";
$string.="'".$data[$lastname]."',";
$string.="'".Yii::app()->params['clientimporttext']."'";
$string.='),';
}
}
$c++;
}
fclose($handle);
}
It is working fine with windows csv.
but when i create a csv from mac and parse that it is not working.( it cant identify end of line),
also when i open the same windows csv with mac and parse using the same code it is not working.
but when i save it as windows csv. it again works.
so actually wat is the difference between mac csv and windows csv?
Is the delimiter different for these two?
How should i change the code to make it work with both?
auto_detect_line_endings