Loop Issue Counting Year In PHP

后端 未结 10 1199
陌清茗
陌清茗 2021-01-22 10:35

I have created a loop which will display date 2004 to 2014 in a formatted way. But the problem is, it is showing 204 instead of 2004 and continue this till 209.. So, how to show

10条回答
  •  无人共我
    2021-01-22 11:18

    I am not sure why are you doing this by so many loops, use this instead of $yr and you will get the correct year printed:

     str_pad($yr, 2, '0', STR_PAD_LEFT);
    

    Best

提交回复
热议问题