damien275x Posted May 26, 2012 Share Posted May 26, 2012 I have a system that, as it is dealing with EFTPOS and is quite old, requires numbers in raw format, with no decimals For example, 200 will be $2.00, 6050 is $60.50. Now it returns the values with no decimal. What is the correct way I can manipulate variables to echo with the decimal places to the end user? Thankyou in advance! Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 26, 2012 Share Posted May 26, 2012 divide by 100 and user number_format Quote Link to comment Share on other sites More sharing options...
thara Posted May 26, 2012 Share Posted May 26, 2012 use like this $n = 200/100 // ur value divide by 100 $n = number_format ($n, 2); // 2.00 Quote Link to comment Share on other sites More sharing options...
smoseley Posted May 26, 2012 Share Posted May 26, 2012 To add to this... round($val, 2) will round your number to 2 decimal places. number_format($val, 2) will comma-delimit (or delimit per your locale) your number as well money_format('%.2n', $val) will comma-delimit and add your currency symbol (per your locale) setlocale(LC_MONETARY, 'en_US'); will set your monetary locale to US standards (globally). 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.