PHP处理excel cvs表格的方法实例介绍_PHP
程序员文章站
2024-01-21 19:32:46
...
复制代码 代码如下:
$data = array();
//convert a cvs file to an array $data
$handle = fopen("data.csv","r");
while ($curline = fgetcsv($handle, 1000, ",")){
$tmp = array();
$num = count($curline);
for($c=0; $c array_push($tmp, $curline[c]);
}
array_push($data, $tmp);
}
print_r($data);
fclose($handle);
//convert array $data back to a cvs file
$handle = fopen("result.csv","w");
foreach($data as $curline){
if(fputcsv($handle, $curline)==false){
die("cannot write CSV line");
}
}
fclose($handle);
?>
上一篇: 大家帮忙分析下这段函数输出?该如何解决
下一篇: php读取xml有关问题