If you want to piggy-back on an existing PHP function, then version_compare
accepts an operator as a string:
$value1 = 10;
$value2 = 20;
var_dump(version_compare($value1, $value2, '<'));
// true
The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively.
See https://3v4l.org/n0iXN
It's strictly designed for comparing version numbers (e.g 1.2.3.4), but should work fine with anything else numeric. If you don't like the name or the signature, then you can still write your own function that delegates to this, rather than white-listing each specific operator yourself.