Jul
1
2009
1
2009
PHP Format numbers to Indian Numerical System
The numerical system used in India differs from the Western system in terms of the placement of the thousands separator.
Example :
Number -> 1000000
Indian System -> 10,00,000 (Ten Lakh)
Western System -> 1,000,000 (1 Million)
While echoing numbers in PHP it is possible to format numbers with such separators using functions like number_format.
To format a number in the Indian Numerical System the code would be :
<?php
$amount = '100000';
setlocale(LC_MONETARY, 'en_IN');
$amount = money_format('%!i', $amount);
echo $amount;
and the output should be :
1,00,000.00
1. Set the locale.
2. Format the number using money_format.
Popularity: 8% [?]
Tags: php
Related Posts
Subscribe
Recent Posts
- Compile wxwebconnect on Ubuntu 11.04 64 bit
- Disqus Comments Importer Script in PHP
- Beginners’ guide to socket programming with winsock
- Handle multiple socket connections with fd_set and select on Linux
- Beginners guide to socket programming in C on Linux
- Gui whois client in python with wxpython
- Whois client code in C with Linux sockets
- str_replace for C
- Easy to use C/C++ IDE for Ubuntu Linux
- Get local ip in C on linux
Binarytides
Tags
apache
applications
box2d
bsnl
c
chrome
cron
css
database
dns
firefox
flash
freelance
game programming
gd
graphs
hacking
htaccess
html
html5
imagemagick
java
javascript
libpcap
linux
mod rewrite
moneybookers
mootools
mvc
mysql
networking
payment
paypal
php
phpmyadmin
python
ruby
security
Sockets
software
swing
ubuntu
winpcap
winsock
xdebug
An article by Binary Tides





money_format() does not work for windows. How can we make the existing functionality work on windows?
Hello
Yes , the function money_format is not available on Windows.
http://php.net/manual/en/function.money-format.php
So a custom function has to be written for windows.
Thanks… It works as per my requirement….
I have done some modification to remove the decimal points.
$number = 10000;
setlocale(LC_MONETARY, ‘en_IN’); $amount1 = money_format(‘%!.0n’, $number); echo $amount1;
It Does not work properly.