How to Return Number of Array Elements of an Array in PHP?

How to Return Number of Array Elements of an Array in PHP?

  • PHP
  • 1 min read

Here is how to return the number of array elements of an array in PHP.

There is a predefined function count(), which is used to return the number of array elements of an array.

Syntax of count() function:

count(array variable).

Below is a program to display the number of array elements.

<html>
<body>
<?php
$a=array("shibu","software","90000");//here $a is the indexed array
$b=count($a);
echo "The number of array elements are:-".$b;
?>
</body>
</html>

Output: The number of array elements is:-3

See also: