Home >Backend Development >PHP Tutorial >PHP处理excel cvs表格的方法实例介绍_PHP

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

WBOY
WBOYOriginal
2016-06-01 12:07:031097browse
复制代码 代码如下:
<?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>




 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn