Here is a simple function to convert numbers into strings like this:
0 => 0000
1 => 0001
20 => 0020
432 => 0432
<?php
function number_pad($number,$n) {
return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
}
?>
$n indicates how many characters you want.
// optional
$number = 0;
for ($i=1; $i<=50; $i=$i+1){
$number = $number+$i;
echo str_pad($number, 5, "0", STR_PAD_LEFT) . '<br />' ;
}
?>