PHP array: count or sizeof?

后端 未结 8 910
慢半拍i
慢半拍i 2020-11-30 21:27

To find the number of elements in a PHP $array, which is faster/better/stronger?

count($array) or sizeof($array) ?

Ed

8条回答
  •  借酒劲吻你
    2020-11-30 22:19

    According to the website, sizeof() is an alias of count(), so they should be running the same code. Perhaps sizeof() has a little bit of overhead because it needs to resolve it to count()? It should be very minimal though.

提交回复
热议问题