How do I start a for-loop with 01
as opposed to 1
? I\'ve tried the below, but it doesn\'t seem to work.
for ($i = 01; $i <= 12;
You can't really start an integer at 01, you will need to pad the value, probably using str_pad to prefix leading elements to a string:
$value = $i;
if ($i < 10) {
$value = str_pad($i, 2, "0", STR_PAD_LEFT);
}
Note that for different unit types you will obviously need to alter the desired pad_length
.