Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

1 total

On This Page:

  1. 1 Sizeof() vs. Count()

Sizeof() vs. Count()

// from http://digest.phpit.net/archives/23/html/. They didn't cite a source, so I'm not so sure about this.

Quick Tip: use sizeof() instead of count()

If you’re writing a PHP5 script, use the sizeof() function instead of count(). Although the manual says that sizeof() is a simple alias for count(), sizeof() is actually twice as fast, and can give a slight increase in performance, especially when used a lot.

In one of my scripts I saw performance increase by a whole second by using sizeof() instead of count(). I’m not sure why this is, especially since it’s officially an alias, but that’s just the way it is. Use it to your advantage!
1 total

On This Page:

  1. 1 Sizeof() vs. Count()