php pad leading zeros
snippet in php

php 0 padding left

user213


<?php
$input = "Alien";
echo str_pad($input, 10);                      // produces "Alien     "
echo str_pad($input, 10, "-=", STR_PAD_LEFT);  // produces "-=-=-Alien"
echo str_pad($input, 10, "_", STR_PAD_BOTH);   // produces "__Alien___"
echo str_pad($input,  6, "___");               // produces "Alien_"
echo str_pad($input,  3, "*");                 // produces "Alien"
?>

prepend 0 to number php

user9429

str_pad($month, 2, '0', STR_PAD_LEFT); 

php format int to 9 digits with preceding zeroes

user5427

str_pad($input, 9, "0", STR_PAD_LEFT);

php pad leading zeros

user8808

str_pad($value, 8, '0', STR_PAD_LEFT);