PHP - Number: Formatting Numbers as Currency ValuesTag: number, format number, currency Category: PHP Basicpost: 16 Mar 2008 read: 190 PHP Number Tips - Part 11: If you want to format a number as per local or international currency conventions, you can define the target locale and then apply the appropriate monetary format via PHP's money_format( ) function such as the following:
In the above, the listing takes a number and formats it, so it conforms to Indian (INR), American (US), and European (EUR) currency conventions. The set locale( ) function sets the locale and hence conventions for currency displays. Notice that the Indian and American locales differ in their placement of thousand separators while the European locale uses commas instead of decimals. Note that the money_format( ) function is not available in the Windows version of PHP. |
| | Give Your Opinion | Recommend |
|

