array-to-csv.php
4 years ago
date-format.php
4 years ago
request.php
4 years ago
security.php
4 years ago
array-to-csv.php
18 lines
| 1 | <?php |
| 2 | |
| 3 | if (!class_exists('IAWP_Array2CSV')) { |
| 4 | class IAWP_Array2CSV |
| 5 | { |
| 6 | public static function array2csv($data, $delimiter = ',', $enclosure = '"', $escape_char = '\\') |
| 7 | { |
| 8 | $f = fopen('php://memory', 'r+'); |
| 9 | foreach ($data as $item) { |
| 10 | fputcsv($f, $item, $delimiter, $enclosure, $escape_char); |
| 11 | } |
| 12 | rewind($f); |
| 13 | |
| 14 | return stream_get_contents($f); |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 |