Putting it All Together


I am stuck on last exercise.

The error is:
Oops, try again. It looks like 'Support=>Kharazim' is part of $myArray, but it wasn't printed to the page!

      // On the line below, create your own associative array:
    $myArray = array("Support"=>"Kharazim", "Tank"=>"Muradin", "Mage"=>"Kael'Thas", "Assasin"=>"Valla");

      // On the line below, output one of the values to the page:
    echo $myArray["Support"] . '<br />';
      // On the line below, loop through the array and output
      // *all* of the values to the page:
    foreach ($myArray as $role=>$hero) {
        echo $role . ' ' . $hero . '<br />';


Don't know if this will work but try nesting your echo statement in quotation marks and changging the format of your Array to look something like,

//Authoritative Array
    $myArray = array(

    echo $myArray["Support"]; //No need for <br/> on this line
    foreach ($myArray as $role=>$hero) {
        echo "<br>$role=>$hero"; // No need for <br/> on this line as well


Pretty weird but it worked.


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