Mega Code Archive

 
Categories / Php / Data Type
 

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]));  ?>