+2 votes
in Programming Languages by (5.2k 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

0 votes
by (33.5k points)

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.

...