wwfc_barmy_army Posted June 24, 2007 Share Posted June 24, 2007 Hello. I've got a variable called $score and this number can be anywhere between -20 and 20. And i'm trying to use a switch statement instead of a bit if statement, i need to do something like 'between -20 and -15 echo 'this' ' but i think i'm doing it wrong, how do you do 'between' values in a switch statement? Any advice is appreciated. Thanks! Link to comment https://forums.phpfreaks.com/topic/56944-solved-php-switch-between-2-numbers/ Share on other sites More sharing options...
Wildbug Posted June 24, 2007 Share Posted June 24, 2007 switch(1) { case $score >= -20 and $score <= -15: echo 'this'; break; case $score >= -14 and $score <= 20: echo 'that': break; default: echo 'something else': } Or use if(), elseif() Link to comment https://forums.phpfreaks.com/topic/56944-solved-php-switch-between-2-numbers/#findComment-281301 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.