简体   繁体   English

Excel 文件无法被 php 中的 arrays 读取

[英]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我读取了扩展名为 csv 的文件,但每一行都返回字符串,如下所示

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.但是 CSV 被正确引用,至少如果 B 和 D 列中的双引号应该是正确的。

edit: You're using the wrong delimiter.编辑:您使用了错误的分隔符。 The file contains semicolon, while you specify colon.该文件包含分号,而您指定冒号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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