Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the min and max values from a PHP array

Is there a built in PHP function that will allow you get the minimum and maximum values from a PHP array?

If not, what's the most efficient way of doing this for the general case?

like image 354
Alan Storm Avatar asked May 01 '26 03:05

Alan Storm


1 Answers

min and max.

$array = array(1, 2, 3);

$min = min($array);
$max = max($array);
like image 124
Alex Barrett Avatar answered May 03 '26 15:05

Alex Barrett