How can I start a for-loop with 01 instead of 1?

前端 未结 5 1540
面向向阳花
面向向阳花 2021-01-14 05:17

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;          


        
5条回答
  •  离开以前
    2021-01-14 05:45

    for ($i = 01; $i <= 12; $i++) {

                $value = strlen($i);
                if($value==1){
                    $k = "0".$i;
                }else
                {
                    $k=$i;
                }
                echo "";
            }
    

    For loop can not start with 01 so you can do like this as shown above

提交回复
热议问题