Skip to content

Instantly share code, notes, and snippets.

@serebro
Created August 19, 2014 14:11
Show Gist options
  • Save serebro/b5b1ddda1e180fff6c78 to your computer and use it in GitHub Desktop.
Save serebro/b5b1ddda1e180fff6c78 to your computer and use it in GitHub Desktop.
array_find
/**
* @return mixed or false
*/
function array_find($array, $fn) {
$next = current($array);
while ($next) {
$key = key($array);
if (call_user_func_array($fn, [$next, $key])) {
return $next;
}
$next = next($array);
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment