Putting it all Together. Why doesn't this work?


#1


https://www.codecademy.com/en/courses/web-beginner-en-QnQrd/0/7?curriculum_id=5124ef4c78d510dd89003eb8#

My code behaves correctly and as intended.


<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("Name" => "Alex", "Age" => 19, "Religion" => "None");

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


#2

Did you try with lowercase key names?


#3

Same result. The error I'm getting is "Oops, try again. It looks like 'name=>Alex' is part of $myArray, but it wasn't printed to the page!"

Not sure how it's getting that since everything is, indeed printed to the page..


#4

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