How to get length of an array in php?

4 answer(s)
Answer # 1 #

For multidimensional arrays, count($array, COUNT_RECURSIVE) can count all elements including nested arrays.

[2 Month]
Answer # 2 #

Use the built-in count() function: $length = count($array); This returns the number of elements in the array.

[3 Month]
Answer # 3 #

Example:

[2 Month]
Answer # 4 #
$fruits = ["apple", "banana", "orange"];echo count($fruits); // Output: 3
[2 Month]