suess0r Posted May 8, 2007 Share Posted May 8, 2007 If I have a multiplication calculation for a PHP variable, how can I set it to only limit to 2 decimal places (.XX) I'm passing the amount value to a merchant account and it's kicking it back if it's over the 10th decimal spot. Thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/50532-limiting-a-variable-to-only-2-decimals-xx/ Share on other sites More sharing options...
soycharliente Posted May 8, 2007 Share Posted May 8, 2007 http://us.php.net/manual/en/function.number-format.php number_format($number, $decimals) Example: <?php echo number_format(1.33333333333333333, 2); //returns 1.33 ?> There are more parameters, read the documentation to view what else you can do. Quote Link to comment https://forums.phpfreaks.com/topic/50532-limiting-a-variable-to-only-2-decimals-xx/#findComment-248294 Share on other sites More sharing options...
suess0r Posted May 8, 2007 Author Share Posted May 8, 2007 Thanks, works perfectly. Much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/50532-limiting-a-variable-to-only-2-decimals-xx/#findComment-248588 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.