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? 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) ) 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%";} ?> 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. 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 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 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? 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. Link to comment https://forums.phpfreaks.com/topic/77824-solved-checking-s/#findComment-393997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.