Printed Value but answer not Accepted : [Resolved]


#1



The tutorial returns an error when I save & submit.

Error says "Oops, try again. It looks like 'north=>JonSnow' is part of $myArray, but it wasn't printed to the page!"

While on the display window shows the following:
Jon Snow

Jon Snow of the north
Tyrion Lanister of the east
The Viper of the south


<?php
      // On the line below, create your own associative array:
        $myArray = array('north'=>"Jon Snow", 'east'=>"Tyrion Lanister", 'south'=>"The Viper");

      // On the line below, output one of the values to the page:
        echo $myArray['north'] . "<br/><br/>";
        
        foreach($myArray as $k=>$a){
            echo $a . " of the " . $k . "<br/>";
        }
      ?>


#2

This post was flagged by the community and is temporarily hidden.


#3

Update:
This seems to be an issue in the program that checks the answer.

I found the fix in another post. Each key=>value on a different line circumvents the issue.

Fixed code:

// On the line below, create your own associative array:
$myArray = array('north'=>"Jon Snow",
'east'=>"Tyrion Lanister",
'south'=>"The Viper");


Putting it All Together, what a error?
#4

I had checked that possibility before the post. But it did not generate a new result.

Turns out that it was just a strange error. Posted update on this forum page.


#5

This post was flagged by the community and is temporarily hidden.


#6

i have an error: "
Oops, try again. It looks like 'audi=>A5' is part of $myArray, but it wasn't printed to the page!";

but i can't understand what wrong with code:






<?php
// On the line below, create your own associative array:
$myArray = array('audi'=>"A5", 'bmw'=>"5gt", 'kia'=>"ceed", 'ford'=>"focus");

  // On the line below, output one of the values to the page:
 echo $myArray["bmw"];
 echo " ";
  // On the line below, loop through the array and output
  // *all* of the values to the page:
 foreach($myArray as $key=>$value){
       echo $key ."=>". $value;
     }
  ?>
</p>



#7

Try:
$myArray = array('audi'=>"A5",
'bmw'=>"5gt",
'kia'=>"ceed",
'ford'=>"focus");

With each $key=>$value pair of a new line.

in place of

That seems to get around what ever issue it has with determining the answer.


#8

Thank you! Now everything is OK!