Using count() to Iterate Through an Array : count « Data Structure « PHP






Using count() to Iterate Through an Array

 
<?php

    $myarray = array('php', 'is', 'cool');

    for($i = 0; $i < count($myarray); $i++) {

      echo "The value of index $i is: {$myarray[$i]}<BR>\n";

    }
?>
  
  








Related examples in the same category

1.Counting Array Elements
2.Get the size of an array in PHP using the count() function
3.Getting the Number of Lines in a File