diff options
author | Urban Müller | 2007-02-19 15:19:58 +0000 |
---|---|---|
committer | Urban Müller | 2007-02-19 15:19:58 +0000 |
commit | c447d3e31b42f2612a7db46ee723b20ad069f38e (patch) | |
tree | 6b9080bac42c7ece6f779d4a9e472adad07597cf /it.class | |
parent | 815f464aef500c1afaf885a1490eafa931461cd5 (diff) | |
download | itools-c447d3e31b42f2612a7db46ee723b20ad069f38e.tar.gz itools-c447d3e31b42f2612a7db46ee723b20ad069f38e.tar.bz2 itools-c447d3e31b42f2612a7db46ee723b20ad069f38e.zip |
added filter_keys
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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; } +} ?> |