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! 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); 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. 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 Link to comment https://forums.phpfreaks.com/topic/170674-solved-multiplying-a-percentage/#findComment-900223 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.