Putting it All Together


#1


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!


      <?php
      // 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 />';
      } 
      ?>


#2

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,

<p>
<?php
//Authoritative Array
    $myArray = array(
        "Support"=>"Kharazim", 
        "Tank"=>"Muradin", 
        "Mage"=>"Kael'Thas", 
        "Assasin"=>"Valla"
        );

    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
      } 
      ?>
      </p>

#3

Pretty weird but it worked.


#4

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