title: PHP multidimensional array foreach echo value
body: <p>I'm having a hard time wrapping my head around this one. I have an array with different keys/values, I want to do a loop that allows me to put in different code wrappings. I'm working with an array that I'm trying to get as an XML.</p>
  
  <p>This is an example of what I have..
  I have what came with the code commented out and what I'm trying to do just below it in the foreach</p>
  
  <pre><code>// Multidimensional array
  $superheroes = array(
      "spider-man" =&gt; array(
          "name" =&gt; "Peter Parker",
          "email" =&gt; "peterparker@mail.com",
          ),
      "super-man" =&gt; array(
          "name" =&gt; "Clark Kent",
          "email" =&gt; "clarkkent@mail.com",
          ),
      "iron-man" =&gt; array(
          "name" =&gt; "Harry Potter",
          "email" =&gt; "harrypotter@mail.com",
          )
      );
  
  // Printing all the keys and values one by one
      $keys = array_keys($superheroes);
      for($i = 0; $i &lt; count($superheroes); $i++) {
          echo $keys[$i] . "{&lt;br&gt;";
          foreach($superheroes[$keys[$i]] as $key =&gt; $value) {
              // echo $key . " : " . $value . "------";
              echo '&lt;wp:meta_key&gt;'.$value['email'].'&lt;wp:meta_key&gt;';
              echo '&lt;wp:meta_value&gt;&lt;![CDATA['.$value['name'].']]&gt;&lt;/wp:meta_value&gt;';
          }
          echo "}&lt;br&gt;";
      }
  </code></pre>