Created
July 8, 2017 15:54
-
-
Save afsardo/aefabd8a3c36222d6e49df7b284f53b1 to your computer and use it in GitHub Desktop.
String always constant number of characters
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
// Append 0 to the left of the number if needed so the number always has 4 digits | |
$number = 10; | |
echo str_pad($number, 4, "0", STR_PAD_LEFT); | |
// Output: 0010 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment