Getting the length of an array in PHP
In this tutorial, we are going to learn about how to get the length of an array in PHP.
Getting the array length
To get the length of an array, we can use the built-in count()
function in PHP.
The count()
function takes the array as an argument and returns the total number of elements in it.
Here is an example, that gets the length of an users
array:
$users=array("a","b","c");
$length=count($users);
echo $length;
Output:
3