PHP: how to 'cut' my array?

前端 未结 5 1392
Happy的楠姐
Happy的楠姐 2020-12-10 11:23

I have an array

Array
(
    [0] => 0
    [1] => 1
    [2] => 2
    [3] => 3
    [4] => 4
    [5] => 5
)

How can I remove

5条回答
  •  醉梦人生
    2020-12-10 11:55

    Slice it. With a knife.

    Actually, with this:

    array_slice($array, 0, -3);
    

    Assuming you meant cutting off the last 3 elements.

提交回复
热议问题