I have this code that doesn't display the 2nd number after the decimal point. This number is used for money. Example: $125.0 what I need is $125.00 $125.4 what I need is $125.40 Here is the line of code that I need to change: $item_price = $item->sellingStatus->currentPrice; Any help would be appreciated.
Ah sorry, the $ sign breaks it i guess $item_price = money_format('$%i',str_replace("$","",$item->sellingStatus->currentPrice)); PHP:
Markus, That kind of works... I now get two $ symbols and there is no comma when the dollar amount gets into the thousands. However, there is the .00 now instead of 100.0 when it shows $100.00 I really appreciate you working on this. If you can find a solution that would be great.
You can look at the two functions I am using http://php.net/money_format, http://php.net/manual/en/function.floatval.php and http://php.net/number_format which should get you started on a nice solution that works for you. Here is a modified version that should work. $item_price = '$'.number_format(floatval($item->sellingStatus->currentPrice)); PHP:
This works when I take out the $ symbol. It just doesn't add the comma for some reason. $item_price = money_format('%i',str_replace("$","",$item->sellingStatus->currentPrice));
Try doing setlocale(LC_MONETARY, 'en_US'); and also change the "$" to '$' and it should work with the $ symbol included or just change my str_replace with flatval()
That worked good except it now has the big USD between the dollar symbol and the number. Example: $USD 1,349.00
Last try then setlocale(LC_MONETARY, 'en_US'); $item_price = money_format('%(#1n',str_replace('$','',"$1220939938430.00")); echo $item_price; PHP:
Remove the dollar sign before doing number format: <?php $item_price = '$' . number_format(str_replace('$', '', $item->sellingStatus->currentPrice), 2); PHP:
I think it is the way Ebay API works: http://developer.ebay.com/devzone/finding/callref/types/SellingStatus.html#currentPrice http://developer.ebay.com/devzone/finding/callref/types/Amount.html