I would use count() if they are the same, as in my experience it is more common, and therefore will cause less developers reading your code to say "sizeof(), what is that?" and having to consult the documentation.

I think it means sizeof() does not work like it does in C (calculating the size of a datatype). It probably made this mention explicitly because PHP is written in C, and provides a lot of identically named wrappers for C functions (strlen(), printf(), etc)

Answer from alex on Stack Overflow
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ function.count.php
PHP: count - Manual
Returns the number of elements in value. Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface, 1 would be returned, unless value was null, in which case 0 would be returned.
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ func_array_count.asp
PHP count() Function
<?php $cars=array ( "Volvo"=>array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . count($cars)."<br>"; echo "Recursive count: " .
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ php-count-function
PHP count() Function - GeeksforGeeks
April 9, 2025 - The count() function in PHP is used to count the number of elements in an array or the countable properties of an object.
๐ŸŒ
Jobtensor
jobtensor.com โ€บ Tutorial โ€บ PHP โ€บ en โ€บ Array-Functions-count
PHP Built-in count(), Definition, Syntax, Parameters, Examples | jobtensor
The count() function returns the number of elements in an array. ... <?php // Example 1 $cities = array("New York", "Salt Lake", "Tokyo"); echo count($cities) . "<br>"; // Example 2 $persons = array( "Mark" => array(22, "USA"), "Jeff" => array(32, "Germany"), "Mike" => array(28, "Japan") ); ...
๐ŸŒ
w3resource
w3resource.com โ€บ php โ€บ function-reference โ€บ count.php
PHP : count() function - w3resource
August 19, 2022 - The count() function is used to count the elements of an array or the properties of an object.
๐ŸŒ
Dev Lateral
devlateral.com โ€บ home โ€บ guides โ€บ php โ€บ how to use the php count function
How to use the PHP Count Function | Dev Lateral
August 30, 2023 - The count function is a pre-built function in PHP, just like the sleep function, or the mkdir function, that you can use in your codebase to count the number of elements in a given value.
๐ŸŒ
FlatCoding
flatcoding.com โ€บ home โ€บ how to use php count() to get array length
How to Use PHP count() to Get Array Length - FlatCoding
June 22, 2025 - PHP count returns the number of elements in an array or Countable object. Click here to see how it works with examples.
Find elsewhere
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ php tutorial โ€บ php count
PHP count | Working of the PHP count() Method with Examples
April 13, 2023 - When the count() method is called and pass the name of array to it, the count() method calculates how many elements are present in it and return this count as a result. ... Example of PHP count() method for finding the number of elements in an array.
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
Reintech
reintech.io โ€บ blog โ€บ comprehensive-guide-php-count-sizeof-functions
A Comprehensive Guide to PHP's `count()` and `sizeof()` Functions
The count() function is a fundamental tool in PHP development. Its constant-time performance for standard arrays makes it efficient for most use cases, while the recursive mode provides flexibility for nested structures.
๐ŸŒ
Carmatec
carmatec.com โ€บ home โ€บ how to get the length of an array in php: complete guide
How to Get the Length of an Array in PHP: Complete Guide
September 28, 2024 - The most common method to get the length of an array in PHP is by using the built-in count() function.
๐ŸŒ
Pi My Life Up
pimylifeup.com โ€บ home โ€บ using the count() function in php
Using the count() Function in PHP - Pi My Life Up
November 30, 2022 - In this tutorial we teach you how to use the count() function in PHP. This function counts the number of elements in an array.
๐ŸŒ
3D Bay
clouddevs.com โ€บ home โ€บ php guides โ€บ the fundamentals of phpโ€™s count() function
The Fundamentals of PHP's count() Function
December 8, 2023 - It helps in calculating the total number of pages required, given a specific number of items per page. php $itemsPerPage = 10; $totalItems = count($allItems); $totalPages = ceil($totalItems / $itemsPerPage);