You need something like this
setlocale(LC_MONETARY, 'en_US'); $money = 123; echo money_format( '%!#4.2i', $money );
To explain the format string:
- %, this is the required first character
- !, it suppresses the currency symbol,
- # 4, this means that we will have a maximum of 4 digits to the left of the decimal fraction and will be properly justified,
- .2, this indicates 2 decimal places,
- i is a required character that defines conversion characters.
source share