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