code: private function writeLine($pFileHandle, array $pValues)
      {
          // No leading delimiter
          $writeDelimiter = false;
  
          // Build the line
          $line = '';
  
          foreach ($pValues as $element) {
              // Escape enclosures
              $element = str_replace($this->enclosure, $this->enclosure . $this->enclosure, $element);
  
              // Add delimiter
              if ($writeDelimiter) {
                  $line .= $this->delimiter;
              } else {
                  $writeDelimiter = true;
              }
  
              // Add enclosed string
              $line .= $this->enclosure . $element . $this->enclosure;
          }
  
          // Add line ending
          $line .= $this->lineEnding;
  
          // Write to file
          fwrite($pFileHandle, $line);
      }
docs: Write line to CSV file.
  
  @param resource $pFileHandle PHP filehandle
  @param array $pValues Array containing values in a row