Difference between array_push() and $array[] =

前端 未结 9 2038
梦毁少年i
梦毁少年i 2020-12-02 07:06

In the PHP manual, (array_push) says..

If you use array_push() to add one element to the array it\'s better to use $array[]

9条回答
  •  情歌与酒
    2020-12-02 07:41

    array_push — Push one or more elements onto the end of array

    Take note of the words "one or more elements onto the end" to do that using $arr[] you would have to get the max size of the array

提交回复
热议问题