summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class16
1 files changed, 16 insertions, 0 deletions
diff --git a/it.class b/it.class
index 1dad9d7..459691e 100644
--- a/it.class
+++ b/it.class
@@ -256,6 +256,22 @@ function replace($replacements, $string, $p = array())
return $result;
}
+/**
+ * Extract key => value pairs from assoc array by key
+ * @param $array array to filter
+ * @param $keys array of keys to keep
+ */
+function filter_keys($array, $keys)
+{
+ $result = array();
+ $keep = array_flip($keys);
+
+ foreach ($array as $key => $val)
+ if (isset($keep[$key]))
+ $result[$key] = $val;
+
+ return $result;
}
+}
?>