Command: Fputcsv ()
Command format: int fputcsv (resource handle [, array fields [, String delimiter [, String enclosure]]]
Command resolution: Fputcsv () formats a row (passed in fields array) in CSV format and writes to the file specified by handle. Returns the length of the write string, or FALSE if an error occurs. Optional delimiter parameter set field delimiter (only one character is allowed). The default is comma:,. Optional Enclosure parameter Set field field wrap character (only one character allowed). The default is double quotes: ".
Write code (error code):
Copy Code code as follows:
<?php
$users = Array (
Array ("User name", "department", "title");
Array ("User1", "1", "Secretariat", "clerk");
Array ("User2", "2", "Office", "clerk");
Array ("User3", "3", "Logistics Office", "clerk");
);
$handle = fopen ("Html/csvfile.csv", "w");
foreach ($users as $line) {
Fputcsv ($user, $line);
}
Put the file "please", but remember to "send it back."
Fclose ($handle);
?>
Code resolution: Create a new empty Csvfile.csv file (set manually) in the html/file directory, and then open it with a command, and write the files for the users array.
Error indications:
See this must surely know what wrong. “;” Is the culprit, beginnings Dawu Ah, the original multidimensional array of the connector is "," Ah, the wrong number of components, this error is very covert, do not suffer!
Remember: A multidimensional array of links using the "," (comma) Link
PHP fputcsv () function