Heim  >  Artikel  >  Backend-Entwicklung  >  php格式化数字的小例子 number_format函数的用法举例

php格式化数字的小例子 number_format函数的用法举例

WBOY
WBOYOriginal
2016-07-25 08:57:381317Durchsuche
  1. print number_format(100000.56 );
  2. ?>
复制代码

例2,number_format($n, $p, $t, $d) rounds $n to $p decimal places, using $t as the thousands separator and $d as the decimal separator.

  1. echo "Total charge is ", number_format($total, 2, ".", ","), " Euros";
  2. ?>
复制代码

例3,number_format函数用于English format and Italian format

  1. $a = 1232322210.44;

  2. echo number_format ($a, 2); // English format
  3. echo "\n";
  4. echo number_format ($a, 2, ',', '.'); // Italian format
  5. echo "\n";
  6. ?>
复制代码

例4,输出格式化的数字形式

  1. print "The population of the US is about:";
  2. print number_format(285266237);
  3. ?>
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn