Yesterday i was searching about how to generate and download csv file in php script using array, i google it and found lots of code there but nothing was working according to my requirement then developed this code. Feel free to let me know if you find any bug in the code.
this is an array contain user details i.e. name & email id of users
$output = fopen("php://output", "w");
$header = array_keys($data); // Set all fields of first index of array as a header containing a list of field names for csv
foreach ($data as $row)