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. Link to comment https://forums.phpfreaks.com/topic/199833-php-number-calculation/ 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); Link to comment https://forums.phpfreaks.com/topic/199833-php-number-calculation/#findComment-1048926 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 Link to comment https://forums.phpfreaks.com/topic/199833-php-number-calculation/#findComment-1048940 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 Link to comment https://forums.phpfreaks.com/topic/199833-php-number-calculation/#findComment-1048944 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. Link to comment https://forums.phpfreaks.com/topic/199833-php-number-calculation/#findComment-1048956 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.