PHP loop X amount of times

后端 未结 8 1262
有刺的猬
有刺的猬 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:25

    If $columns is a string you can cast to int and use a simple for loop

    for ($i=1; $i<(int)$columns; $i++) {
       echo '';
    }
    

提交回复
热议问题