Filling an array with numbers sequentially

后端 未结 2 539
执念已碎
执念已碎 2021-01-17 10:03

I have a number (e.g. 6) that is dynamically generated and I would like to fill an array with the numbers 1 through the dynamically generated number (in this example, 6):

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-17 10:33

    Use range:

    $arr = range(1,6);
    // Returns an array of elements from start to limit, inclusive.
    

提交回复
热议问题