我正在使用cms-megento。我想以下列格式顯示價格值:需要在每3位數後使用php添加逗號
每3位數字後加逗號。
例如:
$price = 987536453 ;
Need to print like 987,536,453.
我正在使用cms-megento。我想以下列格式顯示價格值:需要在每3位數後使用php添加逗號
每3位數字後加逗號。
例如:
$price = 987536453 ;
Need to print like 987,536,453.
試試這個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
+ 1爲好概念 – 2014-02-06 06:17:47
@ user1862659謝謝兄弟 –
您可以通過成千上萬
使用number_format
到組您可以使用number_format
或money_format
做到這一點。
number_format - http://in2.php.net/number_format
money_format - http://www.php.net/manual/en/function.money-format.php
你檢查我的答案 –