Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
/*
* Two annoying omissions from PHP are the lack of array_all() and array_any(), which check if
* a condition represented by a callback holds for all or any of the elements in an array.
*/
function array_all(array $arr, $cb) {
foreach ($arr as $e) {
if (!call_user_func($cb, $e)) {
return false;
}
return true;
}
}
function array_any(array $arr, $cb) {
foreach ($arr as $e) {
if (call_user_func($cb, $e)) {
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.