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.... 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 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.... Link to comment https://forums.phpfreaks.com/topic/246649-help-with-variable/#findComment-1266530 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.