我需要将我的数据包含在“已经尝试了几件事情中,但我只是弄乱了我的数据”
我需要输出csv格式化:
“数据”,“数据”,“数据”
我在下面使用和显示的代码是从另一个问题复制而来的。
if (($handle = fopen('DIRTY_'.$val['spider'].'.csv', 'r')) !== false) {
// read each line into an array
while (($data = fgetcsv($handle, 8192, ",")) !== false) {
// build a "line" from the parsed data
$line = join("," , $data );
// if the line has been seen, skip it
if (isset($lines[$line])) continue;
// save the line
$lines[$line] = true;
}
fclose($handle);
}
$contents = '';
foreach ($lines as $line => $bool) $contents .= $line . "\r\n";
file_put_contents($val['spider'].".csv", $contents);
}