Jump to content

[SOLVED] .50 instead of .5


freddyw

Recommended Posts

Ive read abiut the money_format() but i cant seem to make it work.

 

here is my code

 

<?php
$price = $price * 1.02;

              if ( $result != 0 ) 
              {
                echo "You are paying buy credit card. Your ticket has a transaction fee of 2.5%. Your new ticket price is $$price your card has been charged and your ticket will be dispatched shortly. Please make a note of the order id which is $id. Thankyou and enjoy the match";
              }
              else 
              {
                echo "Failed to buy";
              }
?>

 

Its displaying the price as $20.4 which in maths is correct but in money terms looks wrong. If i changed the code to

<?
Your new ticket price is $$price0
?>

 

it would work but only if the new price rounded to a 10. if it the price was 20.41 it would display 20.410 which again looks wrong.

 

is there a way of letting the php know it is money and needs to display 20.40

 

thanks in advnace

Link to comment
https://forums.phpfreaks.com/topic/168527-solved-50-instead-of-5/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.