You are here

public function ArrayCollection::exists in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php \Doctrine\Common\Collections\ArrayCollection::exists()

Tests for the existence of an element that satisfies the given predicate.

Parameters

Closure $p The predicate.:

Return value

boolean TRUE if the predicate is TRUE for at least one element, FALSE otherwise.

Overrides Collection::exists

File

vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php, line 195

Class

ArrayCollection
An ArrayCollection is a Collection implementation that wraps a regular PHP array.

Namespace

Doctrine\Common\Collections

Code

public function exists(Closure $p) {
  foreach ($this->elements as $key => $element) {
    if ($p($key, $element)) {
      return true;
    }
  }
  return false;
}