7. Putting it All Together


#1

I'm not sure what I'm doing wrong. Everything prints out in the result page properly but I get an error message reading:
"Oops, try again. It looks like 'Nissan=>Sentra' is part of $myArray, but it wasn't printed to the page!"

<html>
  <head>
    <title>I am the King of Arrays!</title>
  </head>
  <body>
    <p>
      <?php
      // On the line below, create your own associative array:
        $myArray = array('Nissan'=>'Sentra', 'Toyota'=>'Corrola', 'Mazda'=>'Miata');

      // On the line below, output one of the values to the page:
        echo $myArray['Nissan'] . '<br/ >';
          
      // On the line below, loop through the array and output
      // *all* of the values to the page:
        foreach($myArray as $make=>$model) {
            echo $make . ' makes ' . $model . ' cars.' . '<br />';
        }
      ?>
    </p>
  </body>
</html>

#2

Well I've found a fix through somebody else's post. Apparently, if you do a new line between each item in your array, that fixes it. Although I'm not sure why :confused:


#3

It's probably something to do with their behind the scenes code that checks our work. And I had the same issue, can confirm this worked for me too.


#4

Works with me too:
$myArray = array('Nissan'=>'Sentra',
'Toyota'=>'Corrola',
'Mazda'=>'Miata');


#5