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);}