Created
December 14, 2013 17:37
-
-
Save alemohamad/7962272 to your computer and use it in GitHub Desktop.
Zero Padded Numbers
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
<?php | |
function setZeroPaddedNumber($value, $padding) { | |
return str_pad($value, $padding, "0", STR_PAD_LEFT); | |
} | |
/** | |
* Usage: | |
* | |
* echo setZeroPaddedNumber(123, 4); | |
* // outputs "0123" | |
**/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment