【发布时间】:2015-06-18 23:07:04
【问题描述】:
我在阅读文件夹和打开/输出 csv 数据方面需要帮助,我使用了其他人编写的示例,但没有一个对我有用。
我目前拥有的是这个,但它不输出文件:
$files = scandir($PathToCreate.$version."/"); //scan the folder
foreach($files as $file) { //for each file in the folder
//The following is another example I found but does not output anything I just need to open each file and be able to output / target specific data
$csv = array();
$lines = file($file, FILE_IGNORE_NEW_LINES);
foreach ($lines as $key => $value)
{
$csv[$key] = str_getcsv($value);
}
print_r($csv)
}
【问题讨论】:
-
你的 csv 文件有什么分隔符?
-
“他们都没有工作”没有帮助。你有什么问题?
-
它使用逗号分隔信息
-
你现在得到什么输出,你期望什么?
-
顺便说一句:看看
fgetcsv()函数:php.net/manual/en/function.fgetcsv.php
标签: php csv fgetcsv opencsv scandir