l!m!t Posted April 26, 2010 Share Posted April 26, 2010 I have a form which posts a dollar amount I am trying to figure out how I can add $10 for every $1000 ? so it should do the following $1000 + 10 $2000 + 20 $3000 + 30 How would I go about doing this? The only thing I can think of would be a for loop and to some how break up the values into thousands.. - I am new to PHP so don't fully know all the functions. Any suggestion would be great. Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 26, 2010 Share Posted April 26, 2010 $value * 1.01; or, if for every full thousand: $value = $value + 10 * floor($value/1000); Quote Link to comment Share on other sites More sharing options...
l!m!t Posted April 26, 2010 Author Share Posted April 26, 2010 Hi, Thanks for the help! Is there anyway I can narrow down to only the fist number? The example below kicks out 505O, but I only need one 50 $value=5000; echo $value * 1.01; //result 5050 Quote Link to comment Share on other sites More sharing options...
ignace Posted April 26, 2010 Share Posted April 26, 2010 I was never good at math but this is crazy but I only need one 50 $amount * 0.01 Quote Link to comment Share on other sites More sharing options...
l!m!t Posted April 26, 2010 Author Share Posted April 26, 2010 God.. I must be tired. I was set on a single digit like "10"... I didn't see the result was the actual total. Thanks again for your time. Quote Link to comment 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.