PHP: create a tmp CSV file without creating a real file in file system

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();