+2 votes
in Programming Languages by (40.5k points)
I want to find the number of elements in an array i.e. the length of the array. What function should I use?

1 Answer

+1 vote
by (349k points)
selected by
 
Best answer

You can use the PHP function count(). It returns the number of elements in an array.

Here is an example:

<?php
$arr=array("apple", "banana", "cat", "dog");
echo count($arr);
?>

The above code will return 4.


...