Last active
July 23, 2018 09:05
-
-
Save yano3nora/09f1cf3d789a8e2fbe747aa63247b110 to your computer and use it in GitHub Desktop.
[php: zeropadding/zerosuppress] #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ゼロ埋め(ゼロパディング) | |
echo sprintf('%02d', 1); | |
// 出力結果 01 | |
echo sprintf('%02d', 10); | |
// 出力結果 10 | |
echo sprintf('%02d', 123); | |
// 出力結果 123 | |
echo sprintf('%04d', 1); | |
// 出力結果 0001 | |
# ゼロ消し(ゼロサプレス) | |
$str = '000100'; | |
echo ltrim($str,'0'); | |
// 出力結果:100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment