Michdd Posted November 30, 2008 Share Posted November 30, 2008 Could I use like < and > in switch cases? Like: switch($variable) { case "$range <= 30 && $range >= -30": //do this break; } Link to comment https://forums.phpfreaks.com/topic/134838-quick-question-about-switches/ Share on other sites More sharing options...
kenrbnsn Posted November 30, 2008 Share Posted November 30, 2008 You have to switch on the value "true": <?php switch (true) { case $range <= 30 && $range >= -30: //do this break; ?> Ken Link to comment https://forums.phpfreaks.com/topic/134838-quick-question-about-switches/#findComment-702129 Share on other sites More sharing options...
Michdd Posted November 30, 2008 Author Share Posted November 30, 2008 You have to switch on the value "true": <?php switch (true) { case $range <= 30 && $range >= -30: //do this break; ?> Ken I have a question, I think I can do what I want to do another way, but I have 1 question. If I have an if statement with an elseif clause, and say the first one holds true, will it go onto the elseif? Link to comment https://forums.phpfreaks.com/topic/134838-quick-question-about-switches/#findComment-702131 Share on other sites More sharing options...
corbin Posted November 30, 2008 Share Posted November 30, 2008 No... If that were how it worked, what would be the point of an elseif construct? Link to comment https://forums.phpfreaks.com/topic/134838-quick-question-about-switches/#findComment-702139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.