aboutsummaryrefslogtreecommitdiff
path: root/tests/csv.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/csv.php')
-rw-r--r--tests/csv.php22
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();