PHP 5.3.0 NumberFormatter replacement

In PHP 5.3.0+ (on my local server) I have the intl library installed. I am using the NumberFormatter class. I need to convert floats to various formats (in percent, decimal, currency, etc.).

But on my real server, I have PHP 5.2.14 installed. And I can not update it (I am not the owner).

Do you know (or use) some classes for formatting numbers? Can you recommend something? I need something like NSNumberFormatter in iOS, but in PHP.

+4
source share
1 answer

How about using number_format ? It is quite limited compared to NumberFormatter, but may be enough for your needs.

Another option, which may be more suitable for formatting currencies, is money_format , but this requires that all locales be properly configured on the servers.

Another option is Zend_Currency , which offers a very powerful currency formatting on different local networks, regardless of the server configuration. Zend Framework supports PHP 5.2.x.

+3
source

All Articles