5
The code below compares a value and according to this value generates a percentage and works. But I would like a more practical way, whether function or other structure, because these ranges of values can be very large.
How to simplify the structure below?
if($valor>0 and $valor<=5000){
$percentual = 0.41;
}elseif($valor>5000 and $valor<=10000){
$percentual = 0.42;
}elseif($valor>10000 and $valor<=15000){
$percentual = 0.43;
}elseif($valor>15000 and $valor<=20000){
$percentual = 0.44;
}elseif($valor>20000 and $valor<=25000){
$percentual = 0.5;
}elseif($valor>25000 and $valor<=30000){
$percentual = 0.57;
}elseif($valor>30000 and $valor<=35000){
$percentual = 0.6;
}elseif($valor>35000 and $valor<=40000){
$percentual = 0.8;
}elseif($valor>40000 and $valor<=45000){
$percentual = 0.84;
}elseif($valor>45000 and $valor<=50000){
$percentual = 0.87;
}elseif($valor>50000 and $valor<=55000){
$percentual = 0.92;
}elseif($valor>55000 and $valor<=60000){
$percentual = 1.0;
}elseif($valor>60000 and $valor<=65000){
$percentual = 1.02;
}elseif($valor>65000 and $valor<=70000){
$percentual = 1.23;
}elseif($valor>70000 and $valor<=75000){
$percentual = 1.25;
}elseif($valor>75000 and $valor<=80000){
$percentual = 2;
}else{
$percentual = 5;
}
The "step" between a track and another will always be fixed. In the case of the example above 5000. But the limit may vary, in the above example was 0 to 80000.
Perfect, thank you!
– Pedro Augusto