amg182 Posted September 7, 2011 Share Posted September 7, 2011 Hi guys. I would like one of my varaibles ($VAR1) to have a paricular value depending on another variables value($VAR2). Example would be: if $VAR2 is between 0 - 9 then $VAR1 will =1 if $VAR2 is between 10 - 19 then $VAR1 will =2 if $VAR2 is between 20 - 29 then $VAR1 will =3 if $VAR2 is between 30 - 39 then $VAR1 will =3 etc.... As you can see it is for every VAR1 increment of 10 i would like to increase VAR2 by 1. i did try: $var1=ceil($var2 / 10); But this will only work if i have values of 1-10, 10-20, 30-40 etc... I hope this makes sense.... Quote Link to comment https://forums.phpfreaks.com/topic/246649-help-with-variable/ Share on other sites More sharing options...
ManiacDan Posted September 7, 2011 Share Posted September 7, 2011 But this will only work if i have values of 1-10, 10-20, 30-40 etc... Isn't that...precisely what you want? Why is that solution not correct for you? You could try floor($var2/10)+1; -Dan Quote Link to comment https://forums.phpfreaks.com/topic/246649-help-with-variable/#findComment-1266524 Share on other sites More sharing options...
amg182 Posted September 7, 2011 Author Share Posted September 7, 2011 Legend! Floor +1 did the trick! Thank you so much, was going crazy trying to use ceil.... Quote Link to comment https://forums.phpfreaks.com/topic/246649-help-with-variable/#findComment-1266530 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.