What's the purpose of the hint?



"When using the for loop, you should count the length of the array first, using count().

Otherwise, for each value in the array, the computer will have to count the length again."

Is this just a hint for normal arrays?
So I have not to use it for the associative array which I just created.?

    <title>I am the King of Arrays!</title>
      // On the line below, create your own associative array:
        $myArray = array('small' => 'tablet',
                                    'medium' => 'laptop',
                                    'large' => 'desktop / personal computer');

      // On the line below, output one of the values to the page:
        echo 'My favourite computer is ' . $myArray['medium'] . ' !<br><br>';
      // On the line below, loop through the array and output
      // *all* of the values to the page:
        echo 'Types of computers:<br>';
        foreach ($myArray as $typeof=>$component) {
           echo '- as ' . $typeof . ' type we use ' . $component . '<br>'; 


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.