Difference between array_push() and $array[] =

前端 未结 9 2082
梦毁少年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:34

    explain: 1.the first one declare the variable in array.

    2.the second array_push method is used to push the string in the array variable.

    3.finally it will print the result.

    4.the second method is directly store the string in the array.

    5.the data is printed in the array values in using print_r method.

    this two are same

提交回复
热议问题