如何在每3个数字后用逗号格式化变量?

时间:2012-10-28 18:53:29

标签: php variables smarty

  

可能重复:
  how to reformat a number with commas
  Formatting numbers with thousands separator Smarty PHP
  Format a number with grouped thousands

例如以下代码: -

{php}echo $youtube->_views;{/php}

返回2556789,我希望它的格式如下; 2556789

1 个答案:

答案 0 :(得分:2)

This topic说明了如何做到这一点:

{$myvar|number_format:2:".":","}