Crew-Portal Posted August 27, 2007 Share Posted August 27, 2007 This is not really a help topic but since this board gets not that much traffic I decided to post pretty much everything I know about PHP math here so that n00bs can read this and maybe itll help them! PHP math is very simple to use all you need to do is echo (2 + 2); and it will display 4 you can use these equasions for /,*,-,+ and probably alot more! if you are calling a equasion form another file just put your math equasion in a file called math.php and use include_once. When trying to make an equasion for a random event you need a $varialbe for example <?php $randmath = rand (0,100); echo ($randmath / 453 + 654); ?> This will display alot of numbers. First it will take a random number between 0 and 100 and divide by 453 and add 654. This will produce alot of numbers so to round it you just do <?php $randmath = rand (0,100); echo round($randmath / 453 + 654); ?> This will round it to a whole number. But to round it to a fraction you do <?php $randmath = rand (0,100); echo round($randmath / 453 + 654, 2); ?> This will round it to the 2 nearest decimal places like 56.45 or 456.43 ect... I will post more about PHP Math if this topic is not locked or deleted within 2 days! Enjoy math (Woah that sounded wierd! Never thought I would say that EVER!) Quote Link to comment https://forums.phpfreaks.com/topic/66836-math-help/ Share on other sites More sharing options...
Daniel0 Posted August 27, 2007 Share Posted August 27, 2007 http://php.net/operators.arithmetic http://php.net/math http://php.net/bc That's what you need to know. Something like 1+2 is not an equation (note spelling). It means when two things are equal, but if you only have one thing (i.e. 1+2) then it cannot be an equation. Something like 1+2=3 or 1+x=3 would be an equation. What you are talking about are expressions. Equations are used to state equality between two expressions. Quote Link to comment https://forums.phpfreaks.com/topic/66836-math-help/#findComment-335270 Share on other sites More sharing options...
ricky_vancouver Posted December 11, 2010 Share Posted December 11, 2010 thanks Quote Link to comment https://forums.phpfreaks.com/topic/66836-math-help/#findComment-1145684 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.