I have an array that I want to export to a CSV file, now I know that there is a fputcsv function but I am using version 5.0.4 of PHP so this isn't an option for me.
Is there an alternative method I can use?
Assuming you have a $Data
array, which contains individual arrays for each registry (or line), you may try this:
$Delimiter = '"';
$Separator = ','
foreach($Data as $Line)
{
fwrite($File, $Delimiter.
implode($Delimiter.$Separator.$Delimiter, $Line).$Delimiter."\n");
}
Where $File
is the handle for your file. Put in $Delimiter
, the character you want to put around each field, and in $Separator
, the character to use between fields.