Command: fputcsv()
Command format: int fputcsv ( resource handle [, array fields [, string delimiter [ , string enclosure]]] )
Command parsing: fputcsv() formats a row (passed in the fields array) into CSV format and writes it to the file specified by handle. Returns the length of the written string. If an error occurs, FALSE is returned. The optional delimiter parameter sets the field delimiter (only one character is allowed). The default is comma: ,. The optional enclosure parameter sets the field wrapper (only one character allowed). The default is double quotes: ".
Writing code (Error code):
$users = array(
array("username", "department", "title");
array("user1","1","Secretariat","Officer");
array("user2","2","office","staff");
array("user3","3","Logistics Office","Secretary");
);
$handle = fopen("html/csvfile.csv","w");
foreach($users as $line){
fputcsv($user,$line);
}
//When you "invite" the documents to the elderly, remember to "send them back"
fclose($handle);
?>
Code analysis: Create a new empty csvfile.csv file (manually created) in the html/file directory, and then use command opens it and writes the users array to the file.
Error symptoms: