title: Elegant way to search an PHP array using a user-defined function
body: <p>Basically, I want to be able to get the functionality of C++'s <code>find_if()</code>, Smalltalk's <code>detect:</code> etc.:</p>
  
  <pre><code>// would return the element or null
  check_in_array($myArray, function($element) { return $elemnt-&gt;foo() &gt; 10; });
  </code></pre>
  
  <p>But I don't know of any PHP function which does this. One "approximation" I came up with:</p>
  
  <pre><code>$check = array_filter($myArray, function($element) { ... });
  if ($check) 
      //...
  </code></pre>
  
  <p>The downside of this is that the code's purpose is not immediately clear. Also, it won't stop iterating over the array even if the element was found, although this is more of a nitpick (if the data set is large enough to cause problems, linear search won't be an answer anyway)</p>