I want to evaluate the length of a number (number of digits) and pad the string with blanks depending on the length
The number can be 1 to 6 digits.
1) get the length of the number
2) pad the string with the number of blanks where 6 - string length = number blanks to pad.
For example
123 = "123bbb"
1234 = "1234bb"
12345 = "12345b"
123456 = "123456"
Using the sample code from the online php manual as shown below, I don't get the result they show.
Expand|Select|Wrap|Line Numbers
- $job = 12345;
- echo 'start-';
- echo printf("[%-10s]\n", $job); // left-justification with spaces
- echo '-end';
start-[12345 ] 13-end
Not sure why it prints the 13. And I don't see 10 blanks in the result either.