hi
halojoy here
printf can do more advanced padding if you need this.
But, I use often str_pad() instead of printf,
when you have to just to pad an
integer number with ZEROS '00000' into a string.
This function I like much better, when comes to more simple padding tasks.
Easy to understand 🙂
You can STR_PAD_RIGHT (default) or with STR_PAD_LEFT,
which tells which side the padding ( e.g. '000' ) should be input.
More Info: http://docs.php.net/str_pad
Regards 🙂
halojoy
Example:
number = 34
padding = 00000
with STR_PAD_RIGHT
'34000'
with STR_PAD_LEFT
'00034'