public function filter(callable $callback = null)
    {
        foreach ($this->items as $key => $value) {
            if (
                (!$callback && !(bool)$value) ||
                ($callback && !$callback($value, $key))
            ) {
                unset($this->items[$key]);
            }
        }

        return $this;
    }
public function filter(callable $callback = null)
    {
        foreach ($this->items as $key => $value) {
            if (
                (!$callback && !(bool)$value) ||
                ($callback && !$callback($value, $key))
            ) {
                unset($this->items[$key]);
            }
        }

        return $this;
    }
public function filter ( callable $ callback = null ) { foreach ( $ this -> items as $ key => $ value ) { if ( ( ! $ callback && ! ( bool ) $ value ) || ( $ callback && ! $ callback ( $ value , $ key ) ) ) { unset ( $ this -> items [ $ key ] ) ; } } return $ this ; }
Filter elements from the list

@param  callable|null $callback A function the receives ($value, $key) and must return a boolean to indicate
filter status

@return $this
Filter elements from the list