Sorry, maybe a dumb question, but I have a HUGE problem with one case where I have an int variable with a value of 0 (zero).
switch ($starost_vozila){ case (0): switch ($podaci['tip_motora']){ case ("motor1"): $eko_taksa = 485; break; case ("motor2"): $eko_taksa = 243; break; case ("motor3"): $eko_taksa = 121; break; case ("motor4"): $eko_taksa = 194; break; } break; case ($starost_vozila < 6): switch ($podaci['tip_motora']){ case ("motor1"): $eko_taksa = 485; break; case ("motor2"): $eko_taksa = 243; break; case ("motor3"): $eko_taksa = 121; break; case ("motor4"): $eko_taksa = 194; break; } break; case ($starost_vozila > 5 && $starost_vozila < 11): switch ($podaci['tip_motora']){ case ("motor1"): $eko_taksa = 667; break; case ("motor2"): $eko_taksa = 273; break; case ("motor3"): $eko_taksa = 136; break; case ("motor4"): $eko_taksa = 218; break; } break;
The switch will continue more, but here is my problem, in this piece of code.
If I do not put "case (0):" and use this:
case ($starost_vozila >= 0 && $starost_vozila < 6):
Then the next next case will somehow become active, and it will print out "$ eko_taksa = 667;".
This is all a problem when "$ starost_vozila = 0", but when this number is less than 6 than this example above.
Every var here is an int. Everything works fine, except when "$ starost_vozila = 0" and when I use the "case ($ starost_vozila> = 0 & $ starost_vozila <6):".
I have no idea what's going on ... Oo
Sorry if this is a stupid question. :(
php switch-statement
Gavrisimo
source share