If you are just trying to match a number to a value consider:
$colors = array('red' => 10, 'blue' => 20, 'green' => 30);
$number = 13;
$color = 'white'; // the default color
$getNext = false;
foreach( $colors as $k => v)
{
if ($getNext == true)
{
$color = $k;
$getNext = false;
}
if ($number >= $v) $getNext = true;
}
In this, it only sets the color on the loop after our number is greater than the current number. This will happen on every loop until the number is less than the array's number. Then getNext will never be set to true and the color will not change.
then again it might be easier to do it with the colors descending in the array
$colors = array('green' => 30, 'blue' => 20, 'red' => 10 );
$number = 13;
$color = 'white'; // the default color
foreach( $colors as $k => v)
{
if ($number <= $v) $color = $k;
}
mmm, yes that's much better. So all you have to is load up the array in reverse order with the color and max number pairs. The => in the array just links the colors and the max number, and is not a maths symbol.
hope this helps