php將數(shù)組轉換成csv格式文件輸出的方法_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:php實現(xiàn)字符串首字母大寫和單詞首字母大寫的方法本文實例講述了php實現(xiàn)字符串首字母大寫和單詞首字母大寫的方法。分享給大家供大家參考。具體分析如下: ucfirst可以對字符串首字母進行大小,ucwords可以對字符串中每個單詞的首字母大寫輸出 ?phpprint ucfirst(hello world);print ucwords(iam king of the jungle);?
本文實例講述了php將數(shù)組轉換成csv格式文件輸出的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
<?php $sales = array( array('east','2005-01-01','2005-02-01',12.54), array('west','2005-01-01','2005-02-01',546.33), array('south','2005-01-01','2005-02-01',93.26), array('north','2005-01-01','2005-02-01',945.21), array('All Regions','--','--',1597.34) ); $fh = fopen('file.csv','w') or die("Can't open file.csv"); foreach ($sales as $sales_line) { if (fputcsv($fh, $sales_line) === false) { die("Can't write CSV line"); } } fclose($fh) or die("Can't close file.csv"); ?>希望本文所述對大家的php程序設計有所幫助。
分享:php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法本文實例講述了php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法。分享給大家供大家參考。具體實現(xiàn)方法如下: ?php$fp = fopen('sample.csv','r') or die(can't open file);print table\n;while($csv_line = fgetcsv($fp)) { print 'tr'; for ($i = 0, $j = count($csv_line);
相關PHP教程:
- 相關鏈接:
- 教程說明:
PHP教程-php將數(shù)組轉換成csv格式文件輸出的方法
。