How can I calculate the length of the array in PHP?

To calculate the array's length in PHP, you can use the count() and sizeof() functions that return the number of items in the array. Function sizeof() is the alias of the count() function. The count() function returns 0 for a variable initialized by an empty array but may also return 0 for a variable that is not installed. In this PHP Array Length example, we obtain the array's length using the count() function. Click Execute to run the PHP Array Length Example online and see the result.
Loading...