How can we know the count/number of elements of an array? ~ Interview Questions & Answers

Saturday, June 5, 2010

How can we know the count/number of elements of an array?

2 ways:
a) sizeof($array_name) - This function is an alias of count()
b) count($array_name) - This function returns the number of elements in an array.
Interestingly if you just pass a simple var instead of an array, count() will return 1.

0 comments: