I have very simple array which I want to export into a CSV file, which I alomost done with the help of this How to create and download a csv file from php script?
But I want my own header at the top of the file which is also a array, created myself and looks like this-
$header = array(
'order_id' => 'order_id',
'firstname' => 'firstname',
'lastname' => 'lastname',
'email' => 'email',
'telephone' => 'telephone',
'fax' => 'fax',
'product_id' => 'product_id',
'name' => 'name',
'model' => 'model',
'quantity' => 'quantity',
'price' => 'price',
'currency_value' => 'total',
'order_status' => 'order_status'
);
my original export array is -
Array
(
[0] => Array
(
[order_id] => 195
[firstname] => satyendra
[lastname] => singh
[email] => satyendra.singh43@gmail.com
[telephone] => 9818077908
[fax] =>
[product_id] => 7086
[name] => Bachini Casual Shoes 1511-Navy Blue
[model] => 1511-Navy Blue
[quantity] => 1
[price] => 499.00
[currency_value] => 499.00
[order_status] =>
)
[1] => Array
(
[order_id] => 196
[firstname] => satyendra
[lastname] => singh
[email] => satyendra.singh43@gmail.com
[telephone] => 9818077908
[fax] =>
[product_id] => 7086
[name] => Bachini Casual Shoes 1511-Navy Blue
[model] => 1511-Navy Blue
[quantity] => 1
[price] => 499.00
[currency_value] => 499.00
[order_status] =>
)
)
export is working fine I just want to add this header at the top of my original array so that when I export this I get first row of array as header in my csv file. can any body have some trick to achieve that result