22

In PHP, is it possible to use money_format to display money without showing the currency or at least showing it in an abbreviated form?

Currently, I use:

$money = "1234.56";
setlocale("LC_ALL", "de_DE");
$money = money_format("%n", $money);
Frank Vilea
  • 8,323
  • 20
  • 65
  • 86

3 Answers3

47

!

Seriously. that's the flag:

$money = money_format("%!n", $money);
cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
5

try number_format($money)

http://php.net/manual/en/function.number-format.php

rackemup420
  • 1,600
  • 2
  • 15
  • 37
0
// this if for Malaysia  , you can check according to your locality

$number = new NumberFormatter($locale = 'ms_MS.utf8', NumberFormatter::DECIMAL);
    echo $nmuber->format($amount)."\n"; ## 20,00,00,00,000
// if this give error 
Class 'NumberFormatter' not found
// for this  you can do  you can do a
apt-get install php7.0-intl
Manmeet Khurana
  • 367
  • 2
  • 13