php写入数据到CSV文件的方法,
本文实例讲述了php写入数据到CSV文件的方法。分享给大家供大家参考。具体实现方法如下:
<?php $row = 0; ini_set('max_execution_time', 300); $cate;$item;$value;$us; $fp = fopen("torah1.csv", "w"); if (($handle = fopen("t.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; for ($c=0; $c < $num; $c++) { if($c==0){ $us = $data[$c]; } if($c==1){ $item = explode(" ",$data[$c]); echo "<prE>"; print_r($item); } elseif($c==2){ $value=$data[$c]; } elseif($c==3){ $cate1 = $data[$c]; } else{ } } // end of for loop if($row > 1838) { exit; } fputcsv($fp, array($us,$item[0],$item[1],$item[2],$item[3])); }//End of While }// End of IF fclose($handle); fclose($fp); ?>
希望本文所述对大家的php程序设计有所帮助。
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

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
3 weeks agoByDDD
Saving in R.E.P.O. Explained (And Save Files)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment