In Ruby, any? takes a block and check if given collection has a value that fulfills the block like this:
[1, 2, 3].any? {|v| v > 2} # true
Is there any way to do this in PHP? My current idea is to use array_reduce():
array_reduce(array(1, 2, 3), function($acc, $val) {
return $acc || ($val > 2);
}, false);
But it will itereate all elements in the array, so I guess it's not as good as "any?" in Ruby. How can I return the boolean value as soon as expected value is found in PHP?