php寫入數據到CSV文件的方法_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php從數組中隨機選擇若干不重復元素的方法本文實例講述了php從數組中隨機選擇若干不重復元素的方法。分享給大家供大家參考。具體實現方法如下: 代碼如下:?php /* * $array = the array to be filtered * $total = the maximum number of items to return * $unique = whether or not to remove duplicates bef
本文實例講述了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程序設計有所幫助。
分享:php檢測apache mod_rewrite模塊是否安裝的方法本文實例講述了php檢測apachemod_rewrite模塊是否安裝的方法。分享給大家供大家參考。具體實現方法如下: /** * @title Check if Apache's mod_rewrite is installed. * * @author Pierre-Henry Soria ph7software@gmail.com * @copyright (c) 2013, Pierre-Henry Sori
相關PHP教程:
- 相關鏈接:
- 教程說明:
PHP教程-php寫入數據到CSV文件的方法
。