by program · 14y ago · 0 comments
My conclusion: count() is horribly slow. Always precalculate it, if possible.
https://github.com/php/php-src/blob/master/ext/standard/arra...In PHP they actually check the length of an array at every invocation of count(). As far as I can see the numeric value for length isn't stored anywhere.
It's not count() that's benchmarked here, its the difference between "$a < $b" and "$a < function_call($b)".