title: PHP nested foreach loops: html tables inside of them
body: <p>I need my PHP page to show the following structure: </p>
  
  <pre><code>  &lt;table border="1"&gt;
    &lt;tr&gt;
           &lt;td&gt;Title one&lt;/td&gt;&lt;td&gt;Title two&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
           &lt;td&gt;I'm content one&lt;/td&gt;&lt;td&gt;And here's content two&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>And here’s my php page:</p>
  
  <pre><code>$array = array( array( Title =&gt; "Title one"), array( Title =&gt; "Title two") );
  $array2 = array( array( Content =&gt; "I'm content one"), array( Content =&gt; "And here's content two") );
   $myvar ="Title one";
  
  $htm .="&lt;table border='1'&gt;";
      for ($i=0; $i&lt;=1; $i++) 
      {
          $htm .="&lt;tr&gt;";
          foreach ($array[$i] as $title)
          {   
              $htm .="&lt;td &gt;".$title."&lt;/td&gt;"; 
              foreach($array2 as $b)
              {
                  $content  = $b['Content'];
                      if ($myvar == $title)
                      {
                          $htm .="&lt;tr&gt;&lt;td&gt;".$content."&lt;/td&gt;&lt;/tr&gt;"; 
                      }else
                      {
                          $htm .="&lt;tr&gt;&lt;td &gt;&lt;/td&gt;&lt;/tr&gt;"; 
                      }
  
              } 
          }
      }
  
  $htm .="&lt;/table&gt;";
  echo $htm;
  </code></pre>
  
  <p>Which is outputting: </p>
  
  <pre><code>&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;td &gt;Title one&lt;/td&gt;&lt;tr&gt;&lt;td&gt;I'm content one&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;And here's content two&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td &gt;Title two&lt;/td&gt;&lt;tr&gt;
  &lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td &gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>How can I modify the html outputs to get the structure I need? </p>