Get the first N elements of an array?

后端 未结 5 1541
一整个雨季
一整个雨季 2020-11-27 02:19

What is the best way to accomplish this?

5条回答
  •  醉梦人生
    2020-11-27 03:24

    In the current order? I'd say array_slice(). Since it's a built in function it will be faster than looping through the array while keeping track of an incrementing index until N.

提交回复
热议问题