In PHP, you can read the indexed elements in the array sequentially using the array length.
The count function is used to read the number of elements in the array. The example below is used to read an array of indexes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php $arr=[ "apple", "banana", "orange", "kiwi" ]; $count=count($arr); for($i=0;$i<$count;$i++) { echo "$arr[$i] <br>"; } |
Output:
1 2 3 4 5 6 |
apple banana orange kiwi |