hi
for ($i = 01; $i <= 31; $i++) { echo $i; }
it echo : 1 2 3 ... 31
but i want to echo: 01 02 03 ... 31
what do I do?
for ($i = 1; $i <= 31; $i++) { printf('%02d', $i); }
if i want to store in variable what do i do?
for ($i = 01; $i <= 31; $i++) { $s.=$i; }
$s has 123456...31
i want to $s has 010203040506...31
Use sprintf() instead of printf() and assign it to your variable:
$s .= sprintf('%02d', $i);