From 3c00fa34ec17cb5865de643aa0490772d7724d56 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 10 May 2010 13:58:08 -0300 Subject: Adding filter into CSV export --- tests/csv.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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(); -- cgit v1.2.3