webdancer Posted December 17, 2010 Share Posted December 17, 2010 I am taking a value that is inputted by the user and depending what the number is, a different response will be given. For example, if the number 30 is entered there will be one response or if a 50 is entered it will be something else. My first thought would be to use if/ifelse, but I didn't know if there would be something better to use. The numbers will go up to about 150 in increments of five. I am fairly new to php, and any help would be great, Joseph Link to comment https://forums.phpfreaks.com/topic/222006-i-have-a-question-about-whether-if-or-something-else-would-be-best-to-use/ Share on other sites More sharing options...
mikecampbell Posted December 17, 2010 Share Posted December 17, 2010 You could use a switch statement. http://php.net/manual/en/control-structures.switch.php switch ($number) { case 30: //response one break; case 50: //response two break; //etc } Link to comment https://forums.phpfreaks.com/topic/222006-i-have-a-question-about-whether-if-or-something-else-would-be-best-to-use/#findComment-1148774 Share on other sites More sharing options...
webdancer Posted December 17, 2010 Author Share Posted December 17, 2010 After looking at it, switch seems like it would be the better alternative. Thank you for your help. Joseph Link to comment https://forums.phpfreaks.com/topic/222006-i-have-a-question-about-whether-if-or-something-else-would-be-best-to-use/#findComment-1148778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.