Created
April 25, 2018 09:06
-
-
Save lastday154/7bbfe11c56d115943936566bdaa2f971 to your computer and use it in GitHub Desktop.
Export to csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| https://www.yiiframework.com/extension/csvexport | |
| Yii::import('ext.ECSVExport'); | |
| // for use with array of arrays | |
| $data = array( | |
| array('key1'=>'value1', 'key2'=>'value2') | |
| .... | |
| ) | |
| $filename = 'somewriteablefile.csv'; | |
| $csv = new ECSVExport($data); | |
| $csv->toCSV($filename); // returns string by default | |
| echo file_get_contents($filename); | |
| // gives you something like | |
| key1,key2 | |
| value1,value2 | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment