我想删除Upload
, 并将列中的 0 更改为 888 qty
,以下是我的代码,它使csv
文件内容混乱。如何更正我的代码。谢谢你
$dir = getcwd();
$files = scandir($dir);
foreach ($files as $file)
{
$parts = pathinfo($file);
if($parts['extension']!="csv") continue;
if (($handle = fopen($file, "r")) !== FALSE)
{
$new_content = implode(',', fgetcsv($handle, 1000, ","))."\n";
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$data[12]=substr($data[12],9);
$data[13]=substr($data[13],9);
$data[14]=substr($data[14],9);
$data[42]=888;
$new_content .= implode(',', $data)."\n";
}
fclose($handle);
file_put_contents($file, $new_content);
}
}
测试 csv 文件 http://phplist.xxmn.com/women.csv