Thursday, 15 September 2011

How to Create downloadable CSV files using PHP (Other then comma sperated) -



How to Create downloadable CSV files using PHP (Other then comma sperated) -

hi want create downloadable csv (apostrophe ( ' ) separated) sheet in php.

i using code -

header('content-type: text/csv; charset=utf-8'); header('content-disposition: attachment; filename=sheet.csv'); $output = fopen('php://output', 'w'); fputcsv($output, array('header1','header2','header3'));

now in able download csv file (comma separated want csv file apostrophe ( ' ) separated while run page)

rtfm

int fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' ]] )

so:

header('content-type: text/csv; charset=utf-8'); header('content-disposition: attachment; filename=sheet.csv'); $output = fopen('php://output', 'w'); fputcsv($output, array('header1','header2','header3'), "'");

php csv

No comments:

Post a Comment