FieldTypesArray(); reset($fieldTypes); $i = 0; while(list(,$o) = each($fieldTypes)) { $v = ($o) ? $o->name : 'Field'.($i++); if ($escquote) $v = str_replace($quote,$escquotequote,$v); $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)))); $elements[] = $v; } $s .= implode($sep, $elements).$NEWLINE; } $hasNumIndex = isset($rs->fields[0]); $line = 0; $max = $rs->FieldCount(); while (!$rs->EOF) { $elements = array(); $i = 0; if ($hasNumIndex) { for ($j=0; $j < $max; $j++) { $v = $rs->fields[$j]; if (!is_object($v)) $v = trim($v); else $v = 'Object'; if ($escquote) $v = str_replace($quote,$escquotequote,$v); $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)))); if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote"; else $elements[] = $v; } } else { // ASSOCIATIVE ARRAY foreach($rs->fields as $v) { if ($escquote) $v = str_replace($quote,$escquotequote,trim($v)); $v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)))); if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote"; else $elements[] = $v; } } $s .= implode($sep, $elements).$NEWLINE; $rs->MoveNext(); $line += 1; if ($fp && ($line % $BUFLINES) == 0) { if ($fp === true) echo $s; else fwrite($fp,$s); $s = ''; } } if ($fp) { if ($fp === true) echo $s; else fwrite($fp,$s); $s = ''; } return $s; }