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