Built From Developers For Developers
» Kuikie.com » Snippets » PHP » Strings » PHP. Array to CSV
    Date & Time
    Files & Directories
    User Interface

PHP. Array to CSV

Comma Separated Values (CSV) files are largely used throughout the IT industry to store, transfer or backup data because of its lean, yet perfectly readable structure. The functions bellow show how to convert a PHP array to CSV format.

function array_to_csv($array) {
    $fp = fopen('php://output', 'w');
    foreach ($array as $row) {
        fputcsv($fp, $row);
    return ob_get_clean();
©2012 Sinevia Ltd Terms of Use         Privacy Policy Valid XHTML 1.0 Transitional