Good afternoon,
I am doing a function that returns the value of the postage to pay, where it is provided through intervals, that is:
Weight
Good afternoon,
I am doing a function that returns the value of the postage to pay, where it is provided through intervals, that is:
Weight
Do a while while reducing weight:
$peso = 31;
$valor = 0;
while($peso >= 0){
if( $peso - 30 >= 0 ){
$peso -= 30;
$valor += 20;
}
if( $peso - 3 >= 0 ){
$peso -= 3;
$valor += 6;
}
if( $peso - 2 >= 0 ){
$peso -= 2;
$valor += 4;
}
if( $peso - 1 >= 0 ){
$peso -= 1;
$valor += 3;
}
}
Make sure you do what you need.
$peso = 61;
$valor = 0;
while($peso != 0)
{
if( $peso >= 30)
{
$peso -= 30;
$valor += 20;
}
else if( $peso >= 3){
$peso -= 1;
$valor += 6;
}
else if( $peso >= 2){
$peso -= 1;
$valor += 4;
}
else if( $peso >= 1){
$peso -= 1;
$valor += 3;
}
}
I hope I have helped.