Array length php for loop
- how to check array length in php
- how to check array size in php
- check length in php
- how to get length of array php
Php count
Array count in php...
PHP Array Length
In this PHP tutorial, you shall learn to find the array length, the number of elements in one-dimensional or multi-dimensional arrays, using count() function, with examples.
PHP Array Length
To find the length of an array in PHP, use count() function.
The count() function takes array as an argument, finds and returns the number of elements in the array.
Syntax of count()
The syntax of count() function to find array length is
where
Parameter | Description |
array | Required.
Specifies the array |
mode | Optional. Specifies the mode. Possible values: |
Function Return Value
count() function returns an integer representing number of elements in the array.
You will mostly use the following form of count() function.
We can store the returned value in a variable as shown below.
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 in