Ben Ben - 7 months ago 63
PHP Question

PHP array: count or sizeof?

To find the number of elements in a PHP

, which is faster/better/stronger?



Thanks to Andy Lester, I have refined my question to mean from a multilingual perspective. The manual commenters say

"[sizeof] does not mean the same in
many other languages based on C"

Is this true?


I would use count() if they are the same, as in my experience it is more common, and therefore will cause less developers reading your code to say "sizeof(), what is that?" and having to consult the documentation.

I think it means sizeof() does not work like it does in C (calculating the size of a datatype). It probably made this mention explicitly because PHP is written in C, and provides a lot of identically named wrappers for C functions (strlen(), printf(), etc)