用成千上万的数字格式化数字 [英] Format a number with grouped thousands
本文介绍了用成千上万的数字格式化数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我具有以下功能:
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return __('0 View','mm');
}
return $count. __(' Views','mm');
}
我如何使其格式化数字以在千位中包含逗号?例如,50000应该变成50,000.
How do I make it format a number to include a comma in the thousandths place? For example, 50000 should become 50,000.
推荐答案
使用 number_format()
:
number_format($number);
这篇关于用成千上万的数字格式化数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文