2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PHP 数値の3桁の区切りカンマを打つ

Posted at

目的

  • PHPで数値の3桁の区切りカンマを打つ方法まとめる

情報

方法

  1. number_format関数を使用する。

  2. 例えば「1000」を「1,000」のようにカンマを打ってほしい場合、下記のようにする。実行すると「1,000」が出力される。

    echo number_format(1000);
    
  3. 変数$numに格納された数値の3桁区切りのカンマを打ち、再び変数$numに格納する場合は下記のようにする。

    $num = 1000;
    
    $num = number_format($num);
    
    echo $num;
    

参考文献

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?