I’m using the following to discover the largest integer from 3 values.
<?php
$a = 100;
$b = 200;
$c = -300;
$max = max($a,$b,$c);
foreach( array('a','b','c') as $v) {
if ($$v == $max) {
echo "\$$v is $max and therefore the largest";
break;
}
}
?>
This works perfectly with the output: $b is 200 and therefore the largest
However, I would now like to also output the 2 smallest integers from the 3.
So as well as showing the 1 largest, it would also output the 2 others.
Can someone show me how I can achieve this?
Many thanks for any pointers.
To illustrate Matt answer :