ob_start();
$df = fopen('php://output', 'w');
fputcsv($df, array_keys(reset($yourData)), ';');
foreach ($yourData as $data) {
fputcsv($df, $data, ';');
}
fclose($df);
$csv = ob_get_clean();
ob_start();
$df = fopen('php://output', 'w');
fputcsv($df, array_keys(reset($yourData)), ';');
foreach ($yourData as $data) {
fputcsv($df, $data, ';');
}
fclose($df);
$csv = ob_get_clean();