note 75038 deleted from function.fputcsv by bjori
| From: | bjori@php.net | Date: | Sun, 10 Jun 2007 15:18:17 +0000 |
| Subject: | note 75038 deleted from function.fputcsv by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127351@lists.php.net to get a copy of this message | ||
Note Submitter: rauxbenoit at free dot fr
----
A real alternative to fcsv_put
<?php
if (!function_exists('fputcsv')){
function fputcsv($objFile,$arrData,$strDelimiter=',',$strEnclose='"') {
$strNewLine="\n";
$strToWrite = '';
foreach ($arrData as $strCell){
//Test if numeric
if (!is_numeric($strCell)){
//Escape the enclose
$strCell = str_replace($strEnclose,$strEnclose.$strEnclose,$strCell);
//Not numeric enclose
$strCell = $strEnclose . $strCell . $strEnclose;
}
if ($strToWrite==''){
$strToWrite = $strCell;
} else {
$strToWrite.= $strDelimiter . $strCell;
}
}
$strToWrite.=$strNewLine;
fwrite($objFile,$strToWrite);
}
}
?>