lupld Posted August 9, 2007 Share Posted August 9, 2007 I'd look this up if I knew what to search for.. but here's what I need... I want to set a variable to something different based on which number it is, so I need to have an if statement try if the number is 1-99... <?php if($rnum = "1-9") { $varrnum = "1000"."$rnum"; } if($rnum = "10-99") { $varrnum = "100"."$rnum"; } if($rnum = "100-999") { $varrnum = "10"."$rnum"; } if($rnum = "1000-9999") { $varrnum = "1"."$rnum"; }else{ $varnum = $rnum; } $lup = $varrnum ?> *edit* I know the way this is set up it will look for $rnum to be exactly 10-99.. which is why I am asking how to do this...*/edit* Quote Link to comment https://forums.phpfreaks.com/topic/64027-easy-php-question-i-hope/ Share on other sites More sharing options...
clearstatcache Posted August 9, 2007 Share Posted August 9, 2007 if($rnum >= 1 && $rnum <= 9 ) { $varrnum = "1000"."$rnum"; } else if($rnum >= 10 && $rnum <= 99 ) { $varrnum = "100"."$rnum"; } else if($rnum >= 100 && $rnum <= 999 ) { $varrnum = "10"."$rnum"; } else if($rnum >= 1000 && $rnum <= 9999 ) { $varrnum = "1"."$rnum"; }else{ $varrnum = $rnum; } Quote Link to comment https://forums.phpfreaks.com/topic/64027-easy-php-question-i-hope/#findComment-319156 Share on other sites More sharing options...
lupld Posted August 9, 2007 Author Share Posted August 9, 2007 thanks.. I never thought of using it like that.... Quote Link to comment https://forums.phpfreaks.com/topic/64027-easy-php-question-i-hope/#findComment-319158 Share on other sites More sharing options...
clearstatcache Posted August 9, 2007 Share Posted August 9, 2007 welcum.... Quote Link to comment https://forums.phpfreaks.com/topic/64027-easy-php-question-i-hope/#findComment-319171 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.