LoginSignup
0
0

More than 3 years have passed since last update.

PHP 0を使って桁数を揃える

Last updated at Posted at 2021-01-07

目的

  • PHPのsprintf関数を使用して数値の桁数を合わせる方法をメモ的にまとめる

情報

方法

  • 下記を実行する。

    printf("%'空欄部分を埋めたい文字桁数d\n", 数値);
    
  • 例えば数値「123456789」を「00123456789」としたいときは下記のようになる。

    printf("%'011d\n", 123456789);
    

参考文献

0
0
2

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
0
0