src/Jsonq.php
public function filter(callable $fn, $key = false)
    {
        $this->prepare();

        $data = [];
        foreach ($this->_map as $k => $val) {
            if ($fn($val)) {
                if ($key) {
                    $data[$k] = $val;
                } else {
                    $data[] = $val;
                }
            }
        }

        return $this->prepareResult($data, false);
    }
public function filter(callable $fn, $key = false)
    {
        $this->prepare();

        $data = [];
        foreach ($this->_map as $k => $val) {
            if ($fn($val)) {
                if ($key) {
                    $data[$k] = $val;
                } else {
                    $data[] = $val;
                }
            }
        }

        return $this->prepareResult($data, false);
    }
public function filter ( callable $ fn , $ key = false ) { $ this -> prepare ( ) ; $ data = [ ] ; foreach ( $ this -> _map as $ k => $ val ) { if ( $ fn ( $ val ) ) { if ( $ key ) { $ data [ $ k ] = $ val ; } else { $ data [ ] = $ val ; } } } return $ this -> prepareResult ( $ data , false ) ; }
filtered each element of prepared data

@param callable $fn
@param bool $key
@return mixed|array
@throws ConditionNotAllowedException
filtered each element of prepared data