count() function is used to count the number of elements in an array.

<?php
$array = array("apple", "banana", "cherry");
$count = count($array);
echo "Number of elements: " . $count;
?>

Output:

Number of elements: 3