Using array in for and while loop in PHP

Suppose you have an array of 100 elements and you want to retrieve each element then it will be hard to retrieve each element individually. Instead of we can use for loop to retrieve items. See the following example:

$Capitals=array("New Delhi","Washington","Sydney","Tokyo","Paris","Landon","Moscow","Berlin");
for($i=0;$i<9;$i++)
{ 
 echo "<BR> $Capitals[$i]";
}

Output will be :
New Delhi
Washington
Sydney
Tokyo
Paris
Landon
Moscow
Berlin
–Or–
if you want to use while or do while loops, the following while loop would do the same as the for loop:

$Capitals=array("New Delhi","Washington","Sydney","Tokyo","Paris","Landon","Moscow","Berlin");
$i=0;
while($i<9)
{
 echo "<BR> $Capitals[$i]";
 $i=$i+1;
}

output will be same as above.