PHP function of the day: max()

For day 3 of 21 in the “PHP Function of the day” series, I’m going to look at max().  This function takes values and returns the highest value from what you provided.  Let’s take a look.


echo(max(-1,0,1,2,3).'<br />’);

echo(max(array(-1,0,1,2,3)).'<br />’);




See the output


You can provide a comma-delimited list or an array.  You can provide a number or a letter.  I wouldn’t recommend mixing variable types (like asking for the for the max of 1, ‘Bob’, and 97) but beyond that, max should be able to handle whatever you want.

Leave a Reply

Your email address will not be published. Required fields are marked *