Home > Backend Development > PHP Tutorial > Example introduction to the method of processing excel cvs table with PHP_PHP tutorial

Example introduction to the method of processing excel cvs table with PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:10:03
Original
885 people have browsed it

复制代码 代码如下:

<?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 < $num; $c++){ <BR>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,...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template