src/Base/ArrayFunctionsTrait.php
public function filter(Closure $callback): CollectionInterface
    {
        $array = array_filter(
            $this->toArray(),
            $callback,
            ARRAY_FILTER_USE_BOTH
        );

        return static::make(array_values($array));
    }
public function filter(Closure $callback): CollectionInterface
    {
        $array = array_filter(
            $this->toArray(),
            $callback,
            ARRAY_FILTER_USE_BOTH
        );

        return static::make(array_values($array));
    }
public function filter ( Closure $ callback ) : CollectionInterface { $ array = array_filter ( $ this -> toArray ( ) , $ callback , ARRAY_FILTER_USE_BOTH ) ; return static :: make ( array_values ( $ array ) ) ; }
Returns a new filtered collection using a user-defined function.

@param Closure $callback

@return Collection A new collection instance.
Returns a new filtered collection using a user - defined function .