Counting the elements in an array is quite simple.
$myarr = array(1,3,5); $counter = count($myarr);
The $counter variable will now contain the value of 3. However, if your array contains empty values like the following array it would still return 3.
Array (  =>  =>  => 20  => 23 )
This of-course would be problematic in some situations of your script. In order to get the accurate count we can simply use the array_filter function before counting.
$myarr = array_filter($myarr); $counter = count($myarr);
This will now return the value of 2.