diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/csv.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/csv.php b/tests/csv.php index 1d3c5cb..bea8091 100644 --- a/tests/csv.php +++ b/tests/csv.php @@ -5,11 +5,29 @@ /** * Format a value for CSV output. + * + * @param $field + * Field entry. + * + * @return + * Formatted CSV field. */ function csv($field = NULL) { return '"'. preg_replace('/"/', '""', $field) .'",'; } +/** + * Apply filters into the result. + * + * @param $field + * Field entry. + */ +function filter(&$field = NULL) { + // Remove brackets from field content. + $field = str_replace('<', '', $field); + $field = str_replace('>', '', $field); +} + // Import Cinisis Library. require_once '../index.php'; @@ -44,6 +62,10 @@ if ($isis->db) { // Format output. for ($n=1; $n <= $rows; $n++) { $result = $isis->db->read($n); + + // Filter results. + array_walk_recursive($result, 'filter'); + foreach ($format['fields'] as $field) { if (is_array($result[$field['name']])) { echo csv(); |