Converting CSV to PHP Array - issue with end line (CR LF)

前端 未结 2 1301
孤城傲影
孤城傲影 2021-01-19 08:58

I am converting csv file to an array using code bellow. But, problem is that end of the row is CR LF, and it is not detected, so array has wrong offset. CR

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-19 09:20

    Have you tried using fgetcsv()? full info on php.net.

    Example usage from php.net

     $num fields in line $row: 

    \n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c] . "
    \n"; } } fclose($handle); } ?>

提交回复
热议问题