Loop Issue Counting Year In PHP

后端 未结 10 1188
陌清茗
陌清茗 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:08

    This is not standard, but you can add an if loop inside that while loop like this:

    while($x <= 31) 
    {
    if ($yr>=10)
        {
           echo "$x Oct 20$yr
    "; } else { echo "$x Oct 200$yr
    "; } $x++; }

    While you'd wanna do something like this beats me though

提交回复
热议问题