PHP loop X amount of times

后端 未结 8 1261
有刺的猬
有刺的猬 2020-12-17 17:55

I have a string called $columns which dynamically gets a value from 1 to 7. I want to create a loop of for however many times

8条回答
  •  Happy的楠姐
    2020-12-17 18:45

    just repeat $n times? ... if dont mind that $n goes backwards... the advantage is that you can see/config "times" at the beginning

    $n = 5;
    while (--$n >= 0)
    {
      // do something, remember that $n goes backwards;
    }
    

提交回复
热议问题