How to insert an item at the beginning of an array in PHP?

后端 未结 9 797
萌比男神i
萌比男神i 2020-12-02 14:53

I know how to insert it to the end by:

$arr[] = $item;

But how to insert it to the beginning?

9条回答
  •  情歌与酒
    2020-12-02 15:39

    Use array_unshift() to insert the first element in an array.

    User array_shift() to removes the first element of an array.

提交回复
热议问题