+1 vote
in Programming Languages by (3.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 (29.3k 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.

...