-
-
Notifications
You must be signed in to change notification settings - Fork 13
IEnumerable.where() method
Marcel Kloubert edited this page Sep 30, 2015
·
5 revisions
Filters the elements of that sequence (s. Where()).
public function where(predicate $predicate) : IEnumerable;
Name | Type | Description |
---|---|---|
$predicate | [[predicate | Predicate]] |
The condition to use.
The new filtered sequence.
use \System\Linq\Enumerable;
$seq = Enumerable::create([1, 2, 3, 4, 5, 6, 8]);
foreach ($seq->where('$i => ($i % 2) === 0') as $item) {
// [0] 2
// [1] 4
// [2] 6
// [3] 8
}
use \System\Linq\Enumerable;
$seq = Enumerable::create([1, 2, 3, 4, 5, 6, 8]);
foreach ($seq->where(function($i) {
return ($i % 2) === 0;
}) as $item) {
// [0] 2
// [1] 4
// [2] 6
// [3] 8
}