What's better to use in PHP, $array[] = $value or array_push($array, $value)?

前端 未结 10 1177
野性不改
野性不改 2020-12-02 01:28

What\'s better to use in PHP for appending an array member,

$array[] = $value;

or

array_push($array, $value);
10条回答
  •  心在旅途
    2020-12-02 02:22

    Second one is a function call so generally it should be slower than using core array-access features. But I think even one database query within your script will outweight 1.000.000 calls to array_push().

提交回复
热议问题