In this tutorial, we are going to see how to count all the elements of an array in PHP. You can use count() or sizeof() function to get the number of elements or values in an array. count() and sizeof() functions return 0 for an empty array, but can also return 0 for an undefined variable.
You can use the isset() function to check whether a variable is set or not.
Count Array Elements in PHP
<?php $langages = array("PHP", "Java", "Python", "HTML"); // Count array elements echo count($langages); echo "<br>"; echo sizeof($langages); ?>