summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorUrban Müller2007-02-19 15:19:58 +0000
committerUrban Müller2007-02-19 15:19:58 +0000
commitc447d3e31b42f2612a7db46ee723b20ad069f38e (patch)
tree6b9080bac42c7ece6f779d4a9e472adad07597cf /it.class
parent815f464aef500c1afaf885a1490eafa931461cd5 (diff)
downloaditools-c447d3e31b42f2612a7db46ee723b20ad069f38e.tar.gz
itools-c447d3e31b42f2612a7db46ee723b20ad069f38e.tar.bz2
itools-c447d3e31b42f2612a7db46ee723b20ad069f38e.zip
added filter_keys
Diffstat (limited to 'it.class')
-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;
}
+}
?>