首頁 >php教程 >php手册 >PHP处理excel cvs表格的方法实例介绍

PHP处理excel cvs表格的方法实例介绍

WBOY
WBOY原創
2016-06-13 11:52:051162瀏覽

复制代码 代码如下:


<?php <BR>$data = array(); <br>//convert a cvs file to an array $data <br>$handle = fopen("data.csv","r"); <br>while ($curline = fgetcsv($handle, 1000, ",")){ <br>$tmp = array(); <br>$num = count($curline); <br>for($c=0; $c array_push($tmp, $curline[c]); <br>} <br>array_push($data, $tmp); <br>} <br>print_r($data); <br>fclose($handle); <br>//convert array $data back to a cvs file <br>$handle = fopen("result.csv","w"); <br>foreach($data as $curline){ <br>if(fputcsv($handle, $curline)==false){ <br>die("cannot write CSV line"); <br>} <br>} <br>fclose($handle); <br>?> <br>




 
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn