getSelectedLicenses($selected_licenses); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="Selected_RecreationalLicenses.csv"'); $output = fopen('php://output', 'w'); // Add CSV headers fputcsv($output, ['lastname', 'firstname', 'Gender', 'ethnicity', 'county', 'city', 'licence_type', 'start_date', 'expire_date'], ',', '"', '\\'); foreach ($licenses as $license) { $last_name = $license->license_last_name; $first_name = $license->license_first_name; $address = "{$license->license_street1} {$license->license_city}, {$license->license_state} {$license->license_zip_code}"; $phone_number = $this->formatPhoneNumber($license->license_phone_number); $email_address = $license->license_email_address; $gender = $license->license_gender; $ethnicity = $license->license_ethnicity; $county = $license->license_county; $license_data = array($last_name, $first_name, $address, $phone_number, $email_address, $gender, $ethnicity, $county); fputcsv($output, $license_data, ',', '"', '\\'); } fclose($output); exit(); } // =============== // Debug an Object // =============== public function debug($object = "") { echo "
";
        print_r($object);
        exit();
    }
}

?>