I am creating a function that returns a number between 0 and 3. If i pass it number 0 it gives me zero back, but if i give it 4, i want it to give me 0 back, it should loop back around.

function BackgroundColor($number){
if($number > 3){
while($number > 3){
$number = $number + -5;
}
}
$colors = array('5db0d7','ea5546','67e15a','e1719e');
return $colors[$number];
//return $number;
}

I need an equation or a function that i can throw a 9 at it and it will work out that it needs to spit back a 1 after looping twice between 0 and 3

Any suggestions?
Solved!

function BackgroundColor($number){
if($number > 3){
while($number > 3){
$number = $number - 4;
}
}
$colors = array('5db0d7','ea5546','67e15a','e1719e');
return $colors[$number];
//return $number;
}