Jump to content


Photo

money_format()


  • Please log in to reply
3 replies to this topic

#1 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 11 August 2006 - 05:35 AM

I am trying to use a function to convert a number such as 91.5 into a currency format without "USD" or "$" before the numbers. I found the money_format function in the php manuel but I can only figure out how to use it two ways:

setlocale(LC_MONETARY, 'en_US');
$thisPrice = '12345.6';

$thisPrice = money_format('%i', $thisPrice) . "\n";
//Converts it to: USD 12,345.60

$thisPrice = money_format('%n', $thisPrice) . "\n";
//Converts it to: $12,345.60

Those would work but I can't have the USD or the dollar sign before the number. Does anyone know how to make this function work or have another function I can use? Thanks!

Michael

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 August 2006 - 05:48 AM

Try...

$thisPrice = money_format('!%n', $thisPrice) . "\n";


#3 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 11 August 2006 - 05:50 AM

I tried that. It just puts an exclamation point before the dollar sign. Any other ideas? Thanks!

Michael

#4 ldsmike88

ldsmike88
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts
  • LocationFlorida

Posted 11 August 2006 - 05:52 AM

I GOT IT!

$thisPrice = money_format('%!n', $thisPrice) . "\n";

Thanks for the exclamation point tip!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users