您现在的位置是:首页 > PHP函数

李清波 2021-06-17 PHP函数 1356 复制当前网址

money_format



PHP money_format() 函数

定义和用法

money_format() 函数把字符串格式化为货币字符串。


语法

money_format(string,number)


参数描述
string必需。规定要格式化的字符串。
number可选。被插入格式化字符串中 % 符号位置的数字。


提示和注释

注释:money_format() 函数无法在 windows 平台上工作。

例子


例子 1

国际 en_US 格式:

<?php
$number = 1234.56;
setlocale(LC_MONETARY, "en_US");
echo money_format("The price is %i", $number);
?>

输出:

The price is USD 1,234.56


例子 2

负数,带有 () 指示负数的 US 国际格式,右侧精度为 2,"*" 为填充字符:

<?php
$number = -1234.5672;

echo money_format("%=*(#10.2n", $number);
?>

输出:

($********1,234.57)


文章来源:http://liqingbo.com/blog-828.html

上一篇:nl_langinfo

下一篇:metaphone

评论