PHP - I have read and used many of the answers, but I keep getting the HTML
of the page as well, how do I stop this!!, or am I just stupid, no don't
answer that. (the new formatted version, sorry guys!!!)
Here is the code:
function WriteCSVFile( $csvArr, $nLine )
{
header( "Content-type: text/csv" );
header( "Content-Disposition: attachment; filename=file.csv" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
header( "Cache-control: private" );
header( "Cache-control: must-revalidate, post-check=0, pre-check=0" );
for( $nLoop = 0; $nLoop <= $nLine; $nLoop++ )
echo $csvArr[$nLoop];
}
text/csvfor CSV files. That should make your browser treat it like a CSV.