我有一个PHP脚本,它汇总了一列。但是,数字格式不正确。
好的 - > ฿4,192.00 不行 - >注入:฿148000
如何在脚本本身中添加千位分隔符(逗号)?
function total_loaned() {
global $wpdb;
$users = $wpdb->get_results( "SELECT SUM(wp_wpdatatable_1.totalloanamount)
as sumed FROM wp_wpdatatable_1");
foreach( $users as $user ) {
echo '<span style="color:#fff;text-align:center;font-size:12px">Injected: ฿'
. $user->sumed;
}
}
add_shortcode('fp_total_loaned', 'total_loaned');
答案 0 :(得分:3)
您可以使用number_format
来实现此目标:
echo number_format($user->sumed, 2, '.', ',');