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.sizeof.php
PHP: sizeof - Manual
If your array is "huge" It is reccomended to set a variable first for this case: THIS-> $max = sizeof($huge_array); for($i = 0; $i < $max;$i++) { code... } IS QUICKER THEN-> for($i = 0; $i < sizeof($huge_array);$i++) { code... } ... a) Always try and use PHP's internal routines to iterate through objects of various types (arrays in most examples below).
🌐
W3Schools
w3schools.com › php › func_array_sizeof.asp
PHP sizeof() Function
The sizeof() function is an alias of the count() function. ... <?php $cars=array ( "Volvo"=>array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . sizeof($cars)."<br>"; echo "Recursive ...
🌐
GitHub
github.com › mrsuh › php-var-sizeof
GitHub - mrsuh/php-var-sizeof: Function for getting size of any PHP variable in bytes · GitHub
Function for getting size of any PHP variable in bytes. It must be more accurate tool to calculate total size of PHP variable than memory_get_usage(), but it has restrictions. var_sizeof() with var_class_sizeof() uses FFI to access internal ...
Author   mrsuh
People also ask

What is the difference between sizeof and count in PHP?
Both functions return the number of elements in an array or object. They are identical in behavior. Example:

$array = array("red", "green", "blue");
echo sizeof($array); // 3
echo count($array);  // 3
🌐
flatcoding.com
flatcoding.com › home › php sizeof: how to count elements in arrays with examples
PHP sizeof: How to Count Elements in Arrays with Examples - FlatCoding
How to use sizeof to count array elements in PHP?
You can use the sizeof function to get the total number of elements in an array. Example:

$array = array("apple", "banana", "orange");
$count = sizeof($array);
echo $count; // Output: 3
🌐
flatcoding.com
flatcoding.com › home › php sizeof: how to count elements in arrays with examples
PHP sizeof: How to Count Elements in Arrays with Examples - FlatCoding
Can sizeof handle multidimensional arrays?
Yes, but it only counts elements in the first level unless you use COUNT_RECURSIVE. Example:

$array = array(
    "fruits" => array("apple", "banana"),
    "colors" => array("red", "blue")
);
echo sizeof($array); // 2
echo sizeof($array, COUNT_RECURSIVE); // 6
🌐
flatcoding.com
flatcoding.com › home › php sizeof: how to count elements in arrays with examples
PHP sizeof: How to Count Elements in Arrays with Examples - FlatCoding
🌐
GeeksforGeeks
geeksforgeeks.org › php › php-sizeof-function
PHP sizeof() Function - GeeksforGeeks
December 2, 2021 - The sizeof() function is a built-in function in PHP and is used to count the number of elements present in an array or any other countable object.
🌐
Jobtensor
jobtensor.com › Tutorial › PHP › en › Array-Functions-sizeof
PHP Built-in sizeof(), Definition, Syntax, Parameters, Examples | jobtensor
The sizeof() function count all elements in an array (alias of count() function). ... <?php // Example 1 $cities = array("New York", "London", "Tokyo", "Berlin", "Cairo"); echo sizeof($cities) . "<br>"; // Example 2 $persons = array( "Mark" => array(22, "USA"), "Jeff" => array(32, "JPN"), "Mike" ...
🌐
w3resource
w3resource.com › php › function-reference › sizeof.php
PHP : sizeof() function - w3resource
August 19, 2022 - The sizeof() function is used to count the elements of an array or the properties of an object. This function is an alias of count(). ... The number of elements in array_name. Value Type: Array.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › php › php_function_sizeof.htm
PHP - Function sizeof()
PHP - Online Compiler · Selected ... Who is Who · Previous · Quiz · Next · sizeof($array, $mode ); Count elements in an array, or properties in an object....
🌐
ZetCode
zetcode.com › php-array › sizeof
PHP sizeof - Array Size in PHP
March 13, 2025 - The PHP sizeof function returns the number of elements in an array.
🌐
Unibo
www-db.disi.unibo.it › courses › PAW › DOCS › w3schools › php › func_array_sizeof.asp.html
PHP sizeof() Function
The sizeof() function is an alias of the count() function. ... <?php $cars=array ( "Volvo"=>array ( "XC60", "XC90" ), "BMW"=>array ( "X3", "X5" ), "Toyota"=>array ( "Highlander" ) ); echo "Normal count: " . sizeof($cars)."<br>"; echo "Recursive count: " .
🌐
Mrsuh
mrsuh.com › projects › php-var-sizeof
PHP var_sizeof()
Function to get the actual size of any PHP variable in bytes. It calculates the size of internal PHP structures along with any additional allocated memory.
🌐
IncludeHelp
includehelp.com › php › sizeof-function-with-example.aspx
PHP Array sizeof() Function (With Examples)
The sizeof() function is an alias of count() function, it is used to get the total number of elements of an array. ... The return type of this method is int, it returns the number of elements in value. Input: $arr1 = array("101", "102", "103", "104", "105"); Output: arr1 has 5 elements · <?php ...
🌐
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 - ... C The length of the array is: 5 In this example, the count() function returns the total number of elements in the array, which is 5. The sizeof() function is an alias of count() in PHP.
🌐
TutorialKart
tutorialkart.com › php › php-sizeof
PHP Array sizeof() - Size of Array
May 7, 2023 - The PHP sizeof() function returns the number of elements in given array. You can also count recursively or not, if the array is nested, using sizeof() function. In this tutorial, we will learn the syntax and usage of sizeof() function, with ...
🌐
Tutorial Republic
tutorialrepublic.com › php-reference › php-sizeof-function.php
PHP sizeof() Function - Tutorial Republic
The following example shows the sizeof() function in action. Run this code » · <?php // Sample array $cars = array("Audi", "BMW", "Mercedes", "Volvo"); // Display array elements count echo sizeof($cars); ?> The sizeof() function accepts two parameters. Note: The sizeof() function may return 0 for a variable that isn't set, or has been initialized with an empty array.
🌐
Medium
medium.com › @jochelle.mendonca › exploring-php-count-vs-sizeof-unveiling-the-differences-a87ca9d57660
xploring PHP: Count vs. Sizeof — Unveiling the Differences | Medium
January 3, 2024 - So, let's shed some light on this PHP quandary and discover which one might be a better fit for your needs. At a glance, both count() and sizeof() may seem like twins separated at birth, but they are, in fact, aliases in PHP. That's right – they are essentially identical in functionality.
🌐
Reintech
reintech.io › blog › comprehensive-guide-php-count-sizeof-functions
A Comprehensive Guide to PHP's `count()` and `sizeof()` Functions
Here's a critical fact that often surprises developers: sizeof() is not a separate function—it's an alias of count(). Both function names point to the exact same internal implementation. This means there's zero performance difference between them, and choosing one over the other is purely a stylistic decision. The PHP community overwhelmingly prefers count() for several reasons: