PHP money_format () function

Source: Internet
Author: User

Definition and usage
The money_format () function returns a string formatted as a currency string.

This function inserts several formatted strings signed by a percent sign (%.

Syntax

Money_format (string, number)
  
Parameter Description
String
Required. Format the specified string and how to format the variable. Possible format value: fill and flag: = F-the specified character (f) will be used for filling (for example, % = T, such as filling in the "T" shape ). Default Space ^-delete group characters + or (-specifies how to display positive and negative numbers. If "+" is used, the local settings + and-will be used (usually a negative number before signing and a positive number before ). If "(" is used, the negative number is enclosed in parentheses. The default value is "+ "! -The currency symbol used to stop is in the output string-if "-" is used, all fields are left aligned. The default value is right-aligned field width: The device-specified minimum field width (x. The default value is 0 #. The number of the specified maximum number (x) is expected to be the decimal place on the left. This is used to keep the same output format in the same column. If the number of digits is greater than 10, this specification will be ignored. -The number of the specified maximum number (x) is expected to be the right decimal point. If x is 0, the number of the decimal point will not be displayed with its right. By default, the conversion character is set locally: I-this number is formatted as the international currency format N-, and the number is formatted as the domestic currency format %-%. The return characters are described as follows: if multiple formats are used for value, they must be in the same order. note: This function is set locally.
Number
Required. Number of format strings to be inserted % sign
  

Tips and instructions
Note: The money_format () function does not work on Windows.




Example 1
International en_US format:

 

<? Php $ number = 1234.56; setlocale (LC_MONETARY, "en_US"); echo money_format ("The price is % I", $ number);?>
 
Result.
 
The price is USD 1,234.56.
 
Instance 2.
 
     

2 decimal places in Norwegian format:

 

<? Php $ number = 1234.56; setlocale (LC_MONETARY, "no_NO"); echo money_format ("%. 2n", $ number);?>
 
Output.
NOK 1.234, 56

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.