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) in CSV format and writes the file specified by handle. Returns the length of the write string, and FALSE if an error occurs. The optional delimiter parameter sets the field delimiter (only one character is allowed). The default is comma:,. The optional Enclosure parameter sets the Field field wrapping character (only one characters allowed). The default is double quotation marks: ".
Write code (error code):
Copy CodeThe code is as follows:
$users = Array (
Array ("User name", "department", "title");
Array ("User1", "1", "Secretariat", "clerk");
Array ("User2", "2", "Office", "clerk");
Array ("User3", "3", "Logistic Office", "clerk");
);
$handle = fopen ("Html/csvfile.csv", "w");
foreach ($users as $line) {
Fputcsv ($user, $line);
}
"Please come" and remember to "send it back".
Fclose ($handle);
?>
Code parsing: Create a new empty Csvfile.csv file (created manually) under the html/file directory, open it with a command, and write a file of the users array.
Error indications:
See this presumably everyone knows what's wrong. “;” Is the culprit, Huanran Dawu Ah, the original multi-dimensional array of the linker is "," ah, mistakenly hit ingredient number, this error is very hidden, do not suffer!
Remember: the links of multidimensional arrays use "," (comma) linked
PHP fputcsv () function
http://www.bkjia.com/PHPjc/323491.html www.bkjia.com true http://www.bkjia.com/PHPjc/323491.html techarticle command: fputcsv () command format: int fputcsv (resource handle [, array fields [, String delimiter [, String enclosure]]) command parsing: FPU Tcsv () adds a row (passed in the fields array ...) .