首頁 >後端開發 >php教程 >PHP处理excel cvs表格的方法实例介绍_PHP教程

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

WBOY
WBOY原創
2016-07-21 15:10:03882瀏覽

复制代码 代码如下:

<?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>




 

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/327169.htmlTechArticle复制代码 代码如下: 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,...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn