@@ 226-242 (lines=17) @@ | ||
223 | * @param $value |
|
224 | * @return array Array of entries that contain $value |
|
225 | */ |
|
226 | static public function filterHasValue(&$arr, $value) |
|
227 | { |
|
228 | $results = array(); |
|
229 | ||
230 | //test what type the value is |
|
231 | $type = gettype($value); |
|
232 | foreach ($arr as $key => $val) { |
|
233 | //we can only compare if the types match |
|
234 | if (gettype($val) === $type) { |
|
235 | if ($val == $value) { |
|
236 | $results[$key] = $val; |
|
237 | } |
|
238 | } |
|
239 | } |
|
240 | ||
241 | return $results; |
|
242 | } |
|
243 | ||
244 | /** |
|
245 | * Filter an array by !value |
|
@@ 250-266 (lines=17) @@ | ||
247 | * @param $value |
|
248 | * @return array Array of entries that do not contain $value |
|
249 | */ |
|
250 | static public function filterHasNotValue(&$arr, $value) |
|
251 | { |
|
252 | $results = array(); |
|
253 | ||
254 | //test what type the value is |
|
255 | $type = gettype($value); |
|
256 | foreach ($arr as $key => $val) { |
|
257 | //we can only compare if the types match |
|
258 | if (gettype($val) === $type) { |
|
259 | if ($val !== $value) { |
|
260 | $results[$key] = $val; |
|
261 | } |
|
262 | } |
|
263 | } |
|
264 | ||
265 | return $results; |
|
266 | } |
|
267 | ||
268 | /** |
|
269 | * Filter by a type, takes internal type or fully qualified class name |