Currency conversion
Posted: Wed May 28, 2008 2:55 am
Hi,
I’m running a small currency test and can’t seem to get a satisfactory output in that either the results is short a numeric value at the end or has an unnecessary one at the beginning.
For example this returns a Euro value of 25.4 and I want to see 25.40
This returns 0.945 and I just want .94 (cent) or 00.94
Is there any specific formula that I can use to get a balanced display or is it more complex that I first imagined?
Thanks
I’m running a small currency test and can’t seem to get a satisfactory output in that either the results is short a numeric value at the end or has an unnecessary one at the beginning.
For example this returns a Euro value of 25.4 and I want to see 25.40
Code: Select all
<?php
$dollar = 40.00 ;
$euro = 0.63 ;
$total = ($dollar * $euro);
echo $total ;// 25.4
?>Code: Select all
<?php
$dollar = 1.50 ;
$euro = 0.63 ;
$total = ($dollar * $euro);
echo $total ;// 0.945
?>Thanks