$value) { $out_csv .= $value.$divider; } $out_csv .= "\n"; foreach ($results as $result) { foreach ($result as $key => $value) { if (preg_match('/Linux/i', $_SERVER['HTTP_USER_AGENT'])) { $value = preg_replace( '/\s+/', ' ', io_safe_output($value) ); } else { $value = mb_convert_encoding( preg_replace( '/\s+/', '', io_safe_output($value) ), 'UTF-16LE', 'UTF-8' ); } $out_csv .= $value.$divider; } $out_csv .= "\n"; } echo io_safe_output($out_csv); exit; }