YaLinqo\Enumerable::where PHP Method

where() public method

Syntax: where (predicate {(v, k) ==> result})

public where ( callable $predicate ) : Enumerable
$predicate callable {(v, k) ==> result} A function to test each element for a condition.
return Enumerable A sequence that contains elements from the input sequence that satisfy the condition.
    public function where($predicate)
    {
        $predicate = Utils::createLambda($predicate, 'v,k');
        return new self(function () use($predicate) {
            foreach ($this as $k => $v) {
                if ($predicate($v, $k)) {
                    (yield $k => $v);
                }
            }
        });
    }