count() and sizeof() – php array function to count the number of items in an array

count — Count all elements in an array, or something in an object.

According to the website, sizeof is an alias of count, so they should be running the same code. Perhaps sizeof has a little bit more lag because it needs to resolve it to count? It should be very minimal though.

Example

<?php
$myArray = array("hen","tiger","bear");
$count = count($myArray);
echo $count;
?>

Output

3