This tutorial shows how to add or append zeros before numbers. You might need this if you want to make folders named by numbers and you want them to be in right order when browsing the folder with your file browser.
Source code viewer
- // How many chars will be in the string.
- $fill = 6;
- // The number.
- $number = 56;
- // With str_pad function the zeros will be added.
- echo str_pad($number, $fill, '0', STR_PAD_LEFT);
- // The result: 000056Programming Language: PHP