marcus Posted October 18, 2006 Share Posted October 18, 2006 Ok, what I'm trying to do is if the user specifies like an answer between 1 - 10, 11 - 20, 21 - 30... etc... that it will echo off something according to the valued answer[code]$rounded = round($answer);if($rounded == 50 - 60){echo "something here";};[/code] Link to comment https://forums.phpfreaks.com/topic/24357-how-would-i-do-something-like-if-num-1-to-another-number/ Share on other sites More sharing options...
LazyJones Posted October 18, 2006 Share Posted October 18, 2006 Not sure what you are trying to achieve, but I'll try...Forget rounding[code]if($answer > 10 && $answer < 21) {echo "Answer is between 10 and 20";} [/code] Link to comment https://forums.phpfreaks.com/topic/24357-how-would-i-do-something-like-if-num-1-to-another-number/#findComment-110800 Share on other sites More sharing options...
kenrbnsn Posted October 18, 2006 Share Posted October 18, 2006 Here is a simple script that illustrates one method:[code]<?php$x = $_GET['a'];switch (true) { case ($x<10): $a = 'less than 10'; break; case ($x>10 && $x<20): $a = 'between 10 and 20'; break; default: $a = '20 or larger';}echo $x . ' is ' . $a;?>[/code]Ken Link to comment https://forums.phpfreaks.com/topic/24357-how-would-i-do-something-like-if-num-1-to-another-number/#findComment-110866 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.