SirChick Posted November 18, 2007 Share Posted November 18, 2007 Is there a built in function to check if a value is a certain % of a different value? Like: If($Value < 10% $value2) sort of thing ? Or do i have to work out the 10% first then check against that? Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/ Share on other sites More sharing options...
Wes1890 Posted November 18, 2007 Share Posted November 18, 2007 Im not sure.. but this is an easy way to do it: if ($value1 < ($value2 / 10) ) Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393890 Share on other sites More sharing options...
MadTechie Posted November 18, 2007 Share Posted November 18, 2007 i don't think theirs a buildin one.. kinda simple to do so, i wouldn't see the point! <?php $vara = 10; $varb = 200; $per = 10; $check = (($vara/$varb)*100); if($check < $per){echo "Less than $per%";} if($check > $per){echo "More than $per%";} if($check == $per){echo "Equal than $per%";} ?> Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393896 Share on other sites More sharing options...
SirChick Posted November 18, 2007 Author Share Posted November 18, 2007 Aye it is simple but cos i use this sort of thing many times in one script on many variables i could of cut my script's size by nearly a 3rd if the function exists hehe but thanks for the help guys shall use what you guys suggested. Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393915 Share on other sites More sharing options...
Wes1890 Posted November 18, 2007 Share Posted November 18, 2007 No problem man.. hit the "solved" button if your done with this topic Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393918 Share on other sites More sharing options...
Blaine0002 Posted November 18, 2007 Share Posted November 18, 2007 % stants for modulus (in code), not percent Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393922 Share on other sites More sharing options...
roopurt18 Posted November 18, 2007 Share Posted November 18, 2007 % stants for modulus (in code), not percent Ever heard of pseudo code? Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393976 Share on other sites More sharing options...
Blaine0002 Posted November 18, 2007 Share Posted November 18, 2007 im not a moron. Its just general information everyone should know.. Thanks for trying to insult me though. Quote Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393997 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.