PHP: Find and Return the Minimum (Lowest) Value or Maximum (Highest) Value of Several Numbers

While you can always make your own function to take on an array of numeric values and find out the highest or lowest value from all of the numbers, PHP has got the inherent functions min() and max() for this kind of job:

print min(24.4, -11, 0.3); // output: -11
print min(array(24.4, -11, 0.3)); // output: -11
print max(24.4, -11, 0.3); // output: 24.4
print max(array(24.4, -11, 0.3)); // output: 24.4
Scroll to Top