ホーム > PHPサンプル > 数値系 > 数値を3桁毎にカンマで区切りたい
PHPサンプル

UPDATE:2017年03月30日

数値を3桁毎にカンマで区切りたい

数値を3桁毎に「,()カンマ」で区切る「number_format()」 PHPサンプルコード[ sample code ] | wepicks!
サンプルコード sample code

数値を3桁毎に「,()カンマ」で区切る number_format()

カンマで区切られた文字列 = number_format(整数や浮動小数点数 [,小数点以下の桁数]);
//[ ]内は省略可能

例:

結果は

123,456,789
123,456,789.123

となります。

数値を3桁毎に「,()カンマ」で区切ります。結果を文字列で返します。浮動小数点数を指定する場合は、引数で小数点以下の表示桁数を指定します。


サンプルコード

– サンプル Click Here ! –

実行結果
数値を3桁毎に「,()カンマ」で区切る「number_format()」
123,456,789
1,000,000,000,000

浮動小数点数を3桁毎に「,()カンマ」で区切る「number_format()」
123,456.654321
123,456.65

– サンプル Click Here ! –


タグ(=記事関連ワード)

タグ: , ,

日付

投稿日:2012年3月2日
最終更新日:2017年03月30日

このカテゴリの他のページ

この記事へのコメント

トラックバックurl

https://wepicks.net/phpsample-int-numfmt/trackback/

page top

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny