From 55652f80494658bf685c2101c6be2abd793592d6 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 5 May 2010 14:50:08 -0300 Subject: CSV export enhancements (2) --- tests/csv.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/csv.php b/tests/csv.php index 2787575..070ee2f 100644 --- a/tests/csv.php +++ b/tests/csv.php @@ -6,7 +6,7 @@ /** * Format a value for CSV output. */ -function csv($field) { +function csv($field = NULL) { return '"'. preg_replace('/"/', '""', $field) .'",'; } @@ -38,17 +38,27 @@ if ($isis->db) { } } + // New roll. + echo "\n"; + // Format output. - for ($n=1; $n <= $rows; $n++) { + for ($n=1; $n <= $n; $n++) { $result = $isis->db->read($n); foreach ($format['fields'] as $field) { - echo csv($result[$field['name']]); + if (is_array($result[$field['name']])) { + echo csv(); + } + else { + echo csv($result[$field['name']]); + } if (is_array($field['subfields'])) { foreach ($field['subfields'] as $key => $value) { echo csv($result[$field['name']][$value]); } } } + + // New roll. echo "\n"; } } -- cgit v1.2.3