getConfiguration(); $field_names = [ "Internal ID", "Location Name", "Template Name", "Date", "Test ID", "Test Cost", ]; fputcsv($handle, $field_names); foreach($tests as $test) { $location = $test->getLocation(); $project = $test->getProject(); $output = []; $output[] = $location->internal_id; $output[] = $location->name; $output[] = $template->name; $output[] = $test->getDateTimeStart()->format("d/m/Y"); $output[] = $test->id; $output[] = bcadd($test->customer_fee ?: $project->default_customer_fee, 0, 2); fputcsv($handle, $output); }