protected function fputcsv($filePointer, $dataArray, $delimiter = ",",   $enclosure = "\"")
  {
    // Build the string
    $string = "";
    // No leading delimiter
    $writeDelimiter = false;
    foreach ($dataArray as $dataElement) {
      // Replaces a double quote with two double quotes
      $dataElement = str_replace("\"", "\"\"", $dataElement);
      // Adds a delimiter before each field (except the first)
      if ($writeDelimiter) {
        $string .= $delimiter;
      }
      // Encloses each field with $enclosure and adds it to the string
      if ($enclosure) {
        $string .= $enclosure . $dataElement . $enclosure;
      } else {
        $string .= $dataElement;
      }
      // Delimiters are used every time except the first.
      $writeDelimiter = true;
    }
    // Append new line
    $string .= "\n";
    // Write the string to the file
    fwrite($filePointer, $string);
  }
protected function fputcsv($filePointer, $dataArray, $delimiter = ",",   $enclosure = "\"")
  {
    // Build the string
    $string = "";
    // No leading delimiter
    $writeDelimiter = false;
    foreach ($dataArray as $dataElement) {
      // Replaces a double quote with two double quotes
      $dataElement = str_replace("\"", "\"\"", $dataElement);
      // Adds a delimiter before each field (except the first)
      if ($writeDelimiter) {
        $string .= $delimiter;
      }
      // Encloses each field with $enclosure and adds it to the string
      if ($enclosure) {
        $string .= $enclosure . $dataElement . $enclosure;
      } else {
        $string .= $dataElement;
      }
      // Delimiters are used every time except the first.
      $writeDelimiter = true;
    }
    // Append new line
    $string .= "\n";
    // Write the string to the file
    fwrite($filePointer, $string);
  }
protected function fputcsv ( $ filePointer , $ dataArray , $ delimiter = "," , $ enclosure = "\"" ) { // Build the string
 $ string = "" ; // No leading delimiter
 $ writeDelimiter = false ; foreach ( $ dataArray as $ dataElement ) { // Replaces a double quote with two double quotes
 $ dataElement = str_replace ( "\"" , "\"\"" , $ dataElement ) ; // Adds a delimiter before each field (except the first)
 if ( $ writeDelimiter ) { $ string .= $ delimiter ; } // Encloses each field with $enclosure and adds it to the string
 if ( $ enclosure ) { $ string .= $ enclosure . $ dataElement . $ enclosure ; } else { $ string .= $ dataElement ; } // Delimiters are used every time except the first.
 $ writeDelimiter = true ; } // Append new line
 $ string .= "\n" ; // Write the string to the file
 fwrite ( $ filePointer , $ string ) ; }
Write a line to a file

@param string $filePointer  File resource to write in
@param array  $dataArray    Data to write out
@param string $delimiter    Field separator
@param string $enclosure    Enclosure
Write a line to a file