think\Collection::filter PHP Method

filter() public method

用回调函数过滤数组中的元素
public filter ( callable $callback = null ) : static
$callback callable
return static
    public function filter(callable $callback = null)
    {
        if ($callback) {
            return new static(array_filter($this->items, $callback));
        }
        return new static(array_filter($this->items));
    }