Format a line as CSV and writes it to an open file in PHP

Description

The following code shows how to format a line as CSV and writes it to an open file.

Example


/* w w  w .  jav  a  2 s.  co m*/
<?php
    $list = array("XML,HTML,CSS,Java","A,B,C,D",);
    $file = fopen("contacts.csv","w");
    foreach ($list as $line){
        fputcsv($file,explode(',',$line));
    }
    
    fclose($file); 
?>




















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip