LoginSignup
0
0

More than 5 years have passed since last update.

【PHP】数字の0埋め方法

Posted at
<?php
$num = 2;
printf('%02d', $num); // 02

$num = 22;
printf('%02d', $num); // 22

sprintfは結果を(最低)何桁にするかを指定できます。
日付の処理とかで便利です。

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