I am just a beginner in php. I am trying to print the array of months using the following code.
<?php
$totalmonth=12;
for($startmonth=01; $startmonth<=$totalmonth; $startmonth++)
{
$montharr[]=$startmonth;
}
print_r($montharr);
?>
My result is Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 )
I need my result should look like this
[0] => 01 [1] => 02
How can i do that?
Use str_pad.