LOUDMOUTH Posted August 17, 2009 Share Posted August 17, 2009 I have this code that updates a number $newenergy = $updated_user->energy + (25 * $num_updated) * $multiplier; I am looking to change it to + 25% * $multiplier Can anyone help me make my current string this way? I am not sure how to use percentages in php. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/170674-solved-multiplying-a-percentage/ Share on other sites More sharing options...
Maq Posted August 17, 2009 Share Posted August 17, 2009 Not sure exactly what you're asking but: (.25 * $multiplier); Quote Link to comment https://forums.phpfreaks.com/topic/170674-solved-multiplying-a-percentage/#findComment-900139 Share on other sites More sharing options...
bobocheez Posted August 17, 2009 Share Posted August 17, 2009 You can just use the decimal equivalent: 25% = 0.25 I'm not sure how the math works in php but you might have to define a floating number. And this should be posted in the math section. Quote Link to comment https://forums.phpfreaks.com/topic/170674-solved-multiplying-a-percentage/#findComment-900167 Share on other sites More sharing options...
LOUDMOUTH Posted August 17, 2009 Author Share Posted August 17, 2009 Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/170674-solved-multiplying-a-percentage/#findComment-900223 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.