代码如下:
<PRE class=php name="code"><?php
$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 < $num; $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);
?>
</PRE><BR>
<BR>
<PRE></PRE>
您可能感兴趣的文章:PHP中创建和编辑Excel表格的方法PHPExcel实现表格导出功能示例【带有多个工作sheet】Thinkphp5+PHPExcel实现批量上传表格数据功能使用PHPExcel实现数据批量导出为excel表格的方法(必看)php上传excel表格并获取数据php通过PHPExcel导入Excel表格到MySQL数据库的简单实例thinkPHP导出csv文件及用表格输出excel的方法php导出word文档与excel电子表格的简单示例代码PHP5.6读写excel表格文件操作示例
cvs
方法
PHP