Share on Google+Share on Google+

PHP Get Array Length

PHP get array length tutorial show you how to count the elements of an array or no. of properties of an object

PHP Get Array Length

 To count the array length we use count method, it can be use to count the no. of properties of an object.

The structure of count is:

int count ($var [,int $mode=COUNT_NORMAL]);


$var is an array

mode is optional and we can set this parameter to COUNT_RECURSIVE (or 1), count() will recursively count the array. This option is beneficial for multidimensional array.Default value for this mode is 0.




$colorList = array("apple"=>"red",





echo "Array size with count: ".count($colorList);



Array size with count: 5



Posted on: October 9, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null