php array length for loop

In this Article, I will explain How to get the size of array and then use the for loop to display all the data into the array.

sizeof :Get the actual length of array in PHP.

Syntax
sizeof(array)
count(array)

Example: Find array length for loop

<?php
$arr1 = array('A','B','C','D','E');
$size= sizeof($arr1); //Get php size of an array


echo "size of an array is:$size<br>";


for($i=0;$i<$size;$i++){
echo $arr1[$i]."<br>";
}
?>


Output:
size of an array is:5
A
B
C
D
E