-
-
Notifications
You must be signed in to change notification settings - Fork 13
IEnumerable.contains() method
Marcel Kloubert edited this page Sep 30, 2015
·
5 revisions
Determines whether the sequence contains a specified element (s. Contains(TSource)).
public function contains(mixed $item
[, equality_comparer $equalityComparer = null ]) : bool;
Name | Type | Description |
---|---|---|
$item | mixed | The element to search for. |
$equalityComparer | [[equality_comparer | Equality comparer]] |
The element to search for.
Compare two elements if they are the same.
TRUE
if element was found; otherwise FALSE
.
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues(5979, 'TM', null);
// (true)
$a1 = $seq->contains("TM");
// (false)
$a2 = $seq->reset()
->contains(23979);
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues('tm', 'MK');
// (true)
$a = $seq->contains("TM", '($x, $y) => 0 === strcasecmp($x, $y)');
use \System\Linq\Enumerable;
$seq = Enumerable::fromValues('tm', 'MK');
// (true)
$a = $seq->contains("MK", function($x, $y) {
return 0 === strcasecmp($x, $y);
});