PHP Code:
<?php
$str = “7”;
echo str_pad($str,3,”0″,STR_PAD_LEFT);
?>

Input Value : 7

Leading Zeros

Output Value: 007