stublackett Posted September 5, 2008 Share Posted September 5, 2008 Hi, I've got a Calculation script running, The problem I have is that when it does the calculation it is not coming out with two decimal points, Its coming out with just one i.e My Script says : Total Cost for this purchase : £175.5 What I'd like it to say is Total Cost for this purchase : £175.50 How do I make this possible? The calculation goes as follows : <?php //Calculate Total $reducedrate = $_POST['reduced_rate']; $newrate = 8.50 * $reducedrate; $total = 150 * $numberofpeople + $newrate; Just for the purposes of this $reducedrate = 4 and numberofpeople = 1 Link to comment https://forums.phpfreaks.com/topic/122841-solved-using-php-to-calculate/ Share on other sites More sharing options...
ranjuvs Posted September 5, 2008 Share Posted September 5, 2008 use number_format function Link to comment https://forums.phpfreaks.com/topic/122841-solved-using-php-to-calculate/#findComment-634396 Share on other sites More sharing options...
ranjuvs Posted September 5, 2008 Share Posted September 5, 2008 $total = number_format($total,2); Link to comment https://forums.phpfreaks.com/topic/122841-solved-using-php-to-calculate/#findComment-634398 Share on other sites More sharing options...
stublackett Posted September 5, 2008 Author Share Posted September 5, 2008 Thanks! *SOLVED* Link to comment https://forums.phpfreaks.com/topic/122841-solved-using-php-to-calculate/#findComment-634399 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.