简体   繁体   中英

Excel file cannot be read by arrays in php

Sorry for my english) I have a problem. I read file with extension,csv but each line returns string, like this

36794;"""Белоснежка""";"9785783314353";"Белоснежка";0;0;""
36795;"""Гуси-лебеди""";"9785783320361";"Гуси-лебеди";1;0;""

I can't convert these strings to array. This is my code.

if (($handle = fopen($local_file, "r")) !== FALSE) {
            while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                $num = count($data);
                $row++;
                for ($c=0; $c < $num; $c++) {
                    echo $data[$c] . "<br />\n";
                }
            }
            fclose($handle);
        }

This is my file. 在此处输入图像描述

Thank you for your help)))

You ask no question actually...

But the CSV is quoted properly, at least if the double quotes ought to be correct in the columns B and D.

edit: You're using the wrong delimiter. The file contains semicolon, while you specify colon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM