Looping Through a Compact Indexed Array Using for and count()
<?php
$birds = array('a', 'b', 'c', 'd');
$limit = count($birds);
for($i = 0; $i < $limit; $i++)
printf("<p>(%d) %s.</p>\n", $i, ucfirst($birds[$i]));
?>
Related examples in the same category