I've created an array with 'maximum' values in.
$management = array(
'100' => '1',
'500' => '2',
'1000' => '3',
);
And created a loop to find the closest value, rounding it up.
$speed = 10;
$r= '';
sort($management);
foreach($management as $mgmt => $name) {
if($mgmt >= $speed) {
$r= $name;
}
}
$r= end($management);
So, where the $speed
is 10
, it should pick up the array key 100
and if it was 100
it should still pickup 100
but if the speed was 200
, it would pickup 500
The above is picking up 500
when the $speed
is 10
though.
Can anyone help please?