| @@ 67-77 (lines=11) @@ | ||
| 64 | * @param $contains string to test for |
|
| 65 | * @return array members of $arr whos key contains $contains |
|
| 66 | */ |
|
| 67 | static public function getKeyContains(&$arr, $contains) |
|
| 68 | { |
|
| 69 | $results = array(); |
|
| 70 | foreach ($arr as $key => $value) { |
|
| 71 | if (($pos = strpos($key, $contains)) !== false) { |
|
| 72 | $results[] = $key; |
|
| 73 | } |
|
| 74 | } |
|
| 75 | ||
| 76 | return $results; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Convenience function to get the first part of a key from an array by a division character |
|
| @@ 153-163 (lines=11) @@ | ||
| 150 | * @param $contains string to test for |
|
| 151 | * @return array members of $arr whos key contains $contains |
|
| 152 | */ |
|
| 153 | static public function filterKeyContains(&$arr, $contains) |
|
| 154 | { |
|
| 155 | $results = array(); |
|
| 156 | foreach ($arr as $key => $value) { |
|
| 157 | if (($pos = strpos($key, $contains)) !== false) { |
|
| 158 | $results[$key] = $value; |
|
| 159 | } |
|
| 160 | } |
|
| 161 | ||
| 162 | return $results; |
|
| 163 | } |
|
| 164 | ||
| 165 | /** |
|
| 166 | * Convenience function to filter arrays by their key !containing a string |
|
| @@ 171-181 (lines=11) @@ | ||
| 168 | * @param $contains string to test for |
|
| 169 | * @return array members of $arr whos key !contains $contains |
|
| 170 | */ |
|
| 171 | static public function filterKeyNotContains(&$arr, $contains) |
|
| 172 | { |
|
| 173 | $results = array(); |
|
| 174 | foreach ($arr as $key => $value) { |
|
| 175 | if (($pos = strpos($key, $contains)) === false) { |
|
| 176 | $results[$key] = $value; |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||
| 180 | return $results; |
|
| 181 | } |
|
| 182 | ||
| 183 | /** |
|
| 184 | * return an array of values filtered by the key starting with $startswith |
|