Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours scrolling social media and waste money on things we forget, but won’t spend 30 minutes a day earning certifications that can change our lives.
Master in DevOps, SRE, DevSecOps & MLOps by DevOps School!
Learn from Guru Rajesh Kumar and double your salary in just one year.

PHP offers count() and sizeof() functions. The count() and sizeof() both functions are used to count all elements in an array and return 0 for a variable that has been initialized with an empty array. These are the built-in functions of PHP. We can use either count() or sizeof() function to count the total number of elements present in an array.
Syntax:
count(array)
Example:-
<?php
$days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
echo 'Total number of elements in the $days array is - ' . count($days);
echo "<br>";
echo 'Total number of elements in the $days array is - ' . sizeof($days);
?>
Output:-
Total number of elements in the $days array is - 7 Total number of elements in the $days array is - 7
Leave a Reply