You can use Array Count function count or sizeof function.

try below code:

$array = array(
    1,
    2,
    3,
    ["thing1", "thing2", "thing3"]
);

echo count($array[3]); //out put 3
echo sizeof($array[3]); //out put 3
Answer from Chetan Ameta on Stack Overflow
🌐
ReqBin
reqbin.com › code › php › iawpnvuz › php-array-length-example
How to get the length of an array in PHP?
It doesn't count all elements of ... following is an example of getting the length of a PHP array using the count() function with the "COUNT_RECURSIVE" parameter....
🌐
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 - This function counts the number of elements in an array and returns the result. ... 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.
Discussions

php - Length array in array - Stack Overflow
However if the array you want to get the length is not always in this same position you could do something like this: More on stackoverflow.com
🌐 stackoverflow.com
How to declare the length/size of an array in php, so users can input any size - Stack Overflow
In PHP you do not have to declare an array size. Just set up the array: ... To create an array with a defined size you have to add the number of elements to the array that you desire when creating. You could do this with array_fill(), for example: More on stackoverflow.com
🌐 stackoverflow.com
I found a website completely about finding the length of an array in PHP.
Random bit of count() trivia: Usually this function is O(1), because arrays store how many elements they contain. However, there is one exception to this: If you do count($GLOBALS) the operation is O(n), because PHP has to scan through the whole array to check for indirectly deleted elements . Now you know. More on reddit.com
🌐 r/PHP
42
36
August 8, 2017
Large Loops
I would strongly advise against sending 20K emails yourself, you are bound to hit the limite pretty soon and it will just crush your domain name's email deliverability, sending everything to people's junk mail folders. When your spam score becomes problematic it can be extremely difficult to bring it back to an acceptable level. You should rather use some hosted service like mailgun , where the 20k emails will cost you about 5$. It is not free but really there is no magic trick to send this kind of volume reliably. Keeping mailgun as an example, you can send up to 1K messages per API call, so you should slice your addresses array into chunks of 1000 so you would only have a 20 occurrence loop, which shouldn't take too much time. More on reddit.com
🌐 r/PHP
25
22
June 27, 2017
People also ask

What is the primary function to get the PHP array length?
The primary and most recommended function to get the php array length is count(). This built-in function is specifically designed to count all the elements in an array or the properties in an object. It is straightforward, efficient, and universally understood by PHP developers. When you need to determine the number of items in any array, count() should be your first choice.  Code Example:PHP$fruits = ["Apple", "Banana", "Cherry"];$length = count($fruits);// $length is now 3
🌐
upgrad.com
upgrad.com › home › blog › software development › php array length: a complete guide to finding array length in php [with examples]
PHP Array Length: Easy Methods to Find Array Size in PHP
How do I properly use the PHP array length in a for loop?
A for loop is a common use case for the php array length. You typically initialize the loop counter at 0 and have it continue as long as the counter is less than the array's length. The length is retrieved once using count() before the loop starts for optimal performance.Code Example:PHP$colors = ["Red", "Green", "Blue"];$length = count($colors);for ($i = 0; $i < $length; $i++) {   echo $colors[$i] . "
";}
🌐
upgrad.com
upgrad.com › home › blog › software development › php array length: a complete guide to finding array length in php [with examples]
PHP Array Length: Easy Methods to Find Array Size in PHP
What is the easiest way to find the length of an array in PHP?
The easiest method is using the count() function, which returns the total number of elements in both indexed and associative arrays.
🌐
guvi.in
guvi.in › blog › web development › php array length: a complete guide to finding array length in php [with examples]
PHP Array Length: A Complete Guide with Examples
🌐
freeCodeCamp
freecodecamp.org › news › php-array-length-how-to-get-an-array-size
PHP Array Length Tutorial – How to Get an Array Size
August 27, 2021 - In this example, count($post_data) will result in 3. This is because there are 3 elements in that array: 'heading', 'subheading', and 'author'. But what about our second, nested array example?
🌐
EDUCBA
educba.com › home › software development › software development tutorials › php tutorial › php array length
PHP array length | How does array length Work in PHP with Examples
April 18, 2023 - PHP array length is defined as an array which is used to get many elements on them. Using the count () function and size of (), we could able to retrieve the count of an element. An array contains either string or integer values which can be either single or multi-dimensional.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Upgrad
upgrad.com › home › blog › software development › php array length: a complete guide to finding array length in php [with examples]
PHP Array Length: Easy Methods to Find Array Size in PHP
3 weeks ago - When you need to determine the number of items in any array, count() should be your first choice. Code Example: PHP $fruits = ["Apple", "Banana", "Cherry"]; $length = count($fruits); // $length is now 3
🌐
GUVI
guvi.in › blog › web development › php array length: a complete guide to finding array length in php [with examples]
PHP Array Length: A Complete Guide with Examples
October 10, 2025 - Learn how to find PHP Array Length using count(), sizeof(), and loops with examples. Master PHP array length calculation easily.
Find elsewhere
🌐
Medium
medium.com › @teamcode20233 › getting-the-length-of-an-array-in-php-3f10f7dd3719
Getting the Length of an Array in PHP | by Teamcode | Medium
May 30, 2023 - Here is an example code that shows how to use the array_pop() function and loop to get the length of an array in PHP.
🌐
Pi My Life Up
pimylifeup.com › home › how to get the length of an array in php
How to get the length of an Array in PHP - Pi My Life Up
October 1, 2022 - To get the length of a multi-dimensional array in PHP you need to use the “COUNT_RECURSIVE” option with the count() function. When “COUNT_RECURSIVE” has been set, the function will loop through the entirety of the array, counting each ...
🌐
DEV Community
dev.to › techyhunger › calculate-php-array-length-2elb
Array Length PHP: Calculate PHP Array Length - DEV Community
August 21, 2019 - ... $food = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard', 'pea')); // recursive count echo count($food, COUNT_RECURSIVE); // output 8 // normal count echo count($food); or count($food, COUNT_NORMAL ...
🌐
Itsourcecode
itsourcecode.com › home › how to find the array length php with examples
How To Find The Array Length PHP With Examples - Itsourcecode.com
December 5, 2022 - The Array Length PHP is the total number of elements present on the given array elements.
🌐
BitDegree
bitdegree.org › learn › php-array-length
Learn About PHP Array Length: PHP Count Function Explained
August 14, 2017 - <?php $fruits = ['Banana', 'Cherry', 'Peach']; $array_length = count($fruits); echo "Result: " .
🌐
Scaler
scaler.com › home › topics › how to find the length of an array in php?
How to Find the Length of an Array in PHP? - Scaler Topics
April 12, 2024 - In PHP, obtaining the size or length of an array is accomplished using the count() function. This function efficiently calculates and returns the total number of elements within an array, regardless of their data types. To get the size of an array: ... In this example, the count() function ...
🌐
TutorialKart
tutorialkart.com › php › php-array-length
How to find length of an array in PHP?
May 7, 2023 - If you pass multidimensional array, count($arr) returns length of array only in the first dimension. If you want to count all elements in a multidimensional array recursively, pass COUNT_RECURSIVE as second argument, as shown in the following code sample. ... We will look into examples for each of these scenarios. This is a simple example to demonstrate the usage of count() function with array. In the following program, we are initializing a PHP array with three numbers as elements.
🌐
Bomberbot
bomberbot.com › php › php-array-length-tutorial-how-to-get-an-array-size
PHP Array Length Tutorial - How to Get an Array Size - Bomberbot
In this tutorial, we explored the concept of arrays in PHP and learned how to get the size or length of an array using the count() function.
🌐
Educative
educative.io › answers › how-to-find-the-length-of-a-php-array
How to find the length of a PHP array
In PHP, we can use the count function to find the length of an array. It accepts an array as its argument and returns an integer.
🌐
W3Schools
w3schools.com › php › func_array_sizeof.asp
PHP sizeof() Function
Arrays Indexed Arrays Associative Arrays Create Arrays Access Array Items Update Array Items Add Array Items Remove Array Items Sorting Arrays Multidimensional Arrays Array Functions PHP Superglobals
🌐
sebhastian
sebhastian.com › php-array-length
PHP how to get an array's length (single and multi-dimensional arrays) | sebhastian
November 8, 2022 - When you want to find the length of a single-dimension array, you need to pass the array as an argument to the count() function as shown below: <?php $days = ["Monday", "Tuesday", "Wednesday"]; // Printing array length print count($days); // 3 print PHP_EOL; print sizeof($days); // 3