public static function filter($array, $filters)
    {
        $result = [];
        $forbiddenVars = [];

        foreach ($filters as $filter) {
            static::applyArrayFilter($array, $filter, $result, $forbiddenVars);
        }

        foreach ($forbiddenVars as $var) {
            list($globalKey, $localKey) = $var;
            if (array_key_exists($globalKey, $result)) {
                unset($result[$globalKey][$localKey]);
            }
        }

        return $result;
    }
public static function filter($array, $filters)
    {
        $result = [];
        $forbiddenVars = [];

        foreach ($filters as $filter) {
            static::applyArrayFilter($array, $filter, $result, $forbiddenVars);
        }

        foreach ($forbiddenVars as $var) {
            list($globalKey, $localKey) = $var;
            if (array_key_exists($globalKey, $result)) {
                unset($result[$globalKey][$localKey]);
            }
        }

        return $result;
    }
public static function filter ( $ array , $ filters ) { $ result = [ ] ; $ forbiddenVars = [ ] ; foreach ( $ filters as $ filter ) { static :: applyArrayFilter ( $ array , $ filter , $ result , $ forbiddenVars ) ; } foreach ( $ forbiddenVars as $ var ) { list ( $ globalKey , $ localKey ) = $ var ; if ( array_key_exists ( $ globalKey , $ result ) ) { unset ( $ result [ $ globalKey ] [ $ localKey ] ) ; } } return $ result ; }
Filters array according to rules specified.

For example:

```php
$array = [
'A' => [1, 2],
'B' => [
'C' => 1,
'D' => 2,
],
'E' => 1,
];

$result = \Reaction\Helpers\ArrayHelper::filter($array, ['A']);
// $result will be:
// [
//     'A' => [1, 2],
// ]

$result = \Reaction\Helpers\ArrayHelper::filter($array, ['A', 'B.C']);
// $result will be:
// [
//     'A' => [1, 2],
//     'B' => ['C' => 1],
// ]

$result = \Reaction\Helpers\ArrayHelper::filter($array, ['B', '!B.C']);
// $result will be:
// [
//     'B' => ['D' => 2],
// ]
```

@param array $array Source array
@param array $filters Rules that define array keys which should be left or removed from results.
Each rule is:
- `var` - `$array['var']` will be left in result.
- `var.key` = only `$array['var']['key'] will be left in result.
- `!var.key` = `$array['var']['key'] will be removed from result.
@return array Filtered array
Filters array according to rules specified .