我正在使用cms - megento.我想以下列格式显示价格值:
每3位数后添加逗号.
例如 :
$price = 987536453 ;
Need to print like 987,536,453.
Run Code Online (Sandbox Code Playgroud)
sca*_*ca_ 21
尝试使用number_format函数.
默认情况下,它每3位数字打印','并删除小数:
echo(number_format(1234));
Run Code Online (Sandbox Code Playgroud)
1,234
试试这个 str_split
$price = 987536453;
$price_text = (string)$price; // convert into a string
$arr = str_split($price_text, "3"); // break string in 3 character sets
$price_new_text = implode(",", $arr); // implode array with comma
echo $price_new_text; // will output 987,536,453
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7983 次 |
| 最近记录: |