PHP Array Elements Count Function

What is count Function?

Explanation

The "count" function counts all the elements in an array, or properties in an object.

Syntax:


count(array,mode)

In the above syntax "array" is the array from which to get the count of elements,"mode" is optional,which can have "0" or "1". If its "0" it will not detect a multidimensional array,if its "1" it will detect a multidimensional array.

Example :


<?php
$b=array("Grapes","Apple","Cherry");
count($b);
print_r($b);
?>
Result :

3

In the above example the total count of an array elements is calculated and displayed.

PHP Topics


Ask Questions

Ask Question