PHP Arrays are collections of items identified and ordered by index.
Array length is just the number of elements it contains. For an array:
<?php $greetings = array( 'Good morning!', 'Good afternoon!', 'Good evening!' ); ?>
The length of array in PHP code above is simply the number of strings contained in it, in this case, that is 3. However, to get the php array length thatâ€™s created or modified on the fly, you need function count().
<?php $length = count($greetings); // $length now equals to 3, which is the length of the php array. ?>
However, for a compound array which contains arrays as elements, the size of the array calculated by php array size function count() would only be taking the first level of elements into account.