Required conversion character in money_format ( string $format , float $number ) function

StackOverflow https://stackoverflow.com/questions/7849781

  •  10-02-2021
  •  | 
  •  

Question

From http://us.php.net/manual/en/function.money-format.php,

It says the $format should consists of the following sequence:

  1. a % character
  2. optional flags
  3. optional field width
  4. optional left precision
  5. optional right precision
  6. a required conversion character

For the number 6 which is the conversion character part, it says we can have three choices:

i - The number is formatted according to the locale's international currency format (e.g. for the USA locale: USD 1,234.56).

n - The number is formatted according to the locale's national currency format (e.g. for the de_DE locale: EU1.234,56).

% - Returns the % character.

I understand i and n, but I don't really understand the use of %.

For example, this works,

http://ideone.com/xxg55

If I use % instead of i in the conversion character part, it produces an error:

http://ideone.com/XmLjY

Was it helpful?

Solution

It's just so that you can write %% if you want a literal % to appear in your output.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top