I have a simple PHP script that is checking the range of a number. For some reason, once the number I am checking equals 100%
the code does not work. Here is my code:
$percent_completed = '100%';
if ($percent_completed <= '20%') {
$color = 'danger';
} elseif ($percent_completed >= '21%' && $percent_completed < '40%') {
$color = 'warning';
} elseif ($percent_completed >= '40%' && $percent_completed < '60%') {
$color = 'info';
} elseif ($percent_completed >= '60%' && $percent_completed < '80%') {
$color = 'primary';
} elseif ($percent_completed >= '80%' && $percent_completed < '100%') {
$color = 'default';
} else {
$color = 'success';
}
echo $color;
All of the conditional checks above work just fine until $percent_completed
is equal to 100%
. For some reason it is set to 100%
the $color
that is printed out is danger
. I am sure it is a simple fix but everything I have tried does not work.