how to import CSV using zend

前端 未结 4 353
故里飘歌
故里飘歌 2021-02-04 09:36

How do I import CSV files using zend framework? Should I use zend_file_transfer or is there any special class that I have to look into? Also if I use zend_file_transfer is there

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-04 10:20

    you don't have to use any zend libraries to import csv files, you can just use native php functions, take a look at fgetcsv

    $row = 1;
    if (($handle = fopen("test.csv", "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            $num = count($data);
            echo "

    $num fields in line $row:

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

提交回复
热议问题