add zeros in front of number php
snippet in php

add zeros in front of number php

user5731

<?php
$num = 4;
$num_padded = sprintf("%02d", $num);
echo $num_padded; // returns 04
?>