I\'ve been thus far unable to find this information in the official PHP docs, or on this site. So, that may mean I\'m searching under the wrong terms, or it is not supported
No, PHP doesn't have anything like this.
You could do something awful like this when you have very large amounts of things to compare.
<?php
$arr = [1, 2, 3];
$less_than = function($a, $b) {
return $a < $b;
};
$greater_than = function($a, $b) {
return $a > $b;
};
function apply_operator($arr, $operator) {
for ($i = 0; $i < sizeof($arr) - 1; $i++) {
if (!$operator($arr[$i], $arr[$i + 1])) {
return false;
}
}
return true;
}
var_dump(apply_operator($arr, $less_than)); // true
var_dump(apply_operator($arr, $greater_than)); // false
But for greater/less than you can just sort and compare to the original, and for equal you can check the size of array_unique
.