PHP converts an array into a CSV-formatted file output method,
This example describes how PHP converts an array to a CSV-formatted file output. Share to everyone for your reference. The implementation method is as follows:
<?php$sales = 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");? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/967735.html www.bkjia.com true http://www.bkjia.com/PHPjc/967735.html techarticle PHP converts an array to a CSV-formatted file output method, and this example describes how PHP converts an array to a CSV-formatted file output. Share to everyone for your reference. Concrete implementation methods such as ...