Qaribou\Collection\ImmArray::filter PHP 메소드

filter() 공개 메소드

Filter out elements
public filter ( callable $cb ) : ImmArray
$cb callable Function to filter out on false
리턴 ImmArray
    public function filter(callable $cb)
    {
        $count = count($this->sfa);
        $sfa = new SplFixedArray($count);
        $newCount = 0;
        foreach ($this->sfa as $el) {
            if ($cb($el)) {
                $sfa[$newCount++] = $el;
            }
        }
        $sfa->setSize($newCount);
        return new static($sfa);
    }