note 47336 deleted from function.fputcsv by danbrown
| From: | danbrown@php.net | Date: | Thu, 20 Nov 2008 14:44:29 +0000 |
| Subject: | note 47336 deleted from function.fputcsv by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146758@lists.php.net to get a copy of this message | ||
Note Submitter: arthur at mclean dot ws
----
Here's a simplistic fputcsv function that you can use until the real one gets out of CVS:
function fputcsv($filePointer, $dataArray, $delimiter, $enclosure){
// Write a line to a file
// $filePointer = the file resource to write to
// $dataArray = the data to write out
// $delimeter = the field separator
// Build the string
$string = "";
$writeDelimiter = FALSE;
foreach($dataArray as $dataElement){
if($writeDelimiter) $string .= $delimiter;
$string .= $enclosure . $dataElement . $enclosure;
$writeDelimiter = TRUE;
} // end foreach($dataArray as $dataElement)
// Append new line
$string .= "\n";
// Write the string to the file
fwrite($filePointer, $string);
} // end function fputcsv($filePointer, $dataArray, $delimiter)