Qaribou\Collection\ImmArray::filter PHP Méthode

filter() public méthode

Filter out elements
public filter ( callable $cb ) : ImmArray
$cb callable Function to filter out on false
Résultat 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);
    }