title: multidimensional array into table in PHP
body: <p>I hope you can help me to finish my assignment. I still new with PHP language. I have a case like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;style&gt;
      table, th, td {
          border: 1px solid black;
          border-collapse: collapse;
      }
      th, td {
          padding: 5px;
          text-align: left;
      }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  $ub = array(
      array(
          "Fakultas Ilmu Komputer",
          array(
              "Jurusan Teknik Informatika",
              array(
                  "Prodi Teknik Informatika",
                  "Prodi Teknik Komputer",
                  "Prodi Magister Ilmu Komputer"
              )
          ),
          array(
              "Jurusan Sistem Informasi",
              array(
                  "Prodi Sistem Informasi",
                  "Prodi Teknologi Informasi",
                  "Prodi Pendidikan Teknologi Informasi"
              )
          )
      ),
      array(
          "Fakultas Kedokteran",
          array(
              "Jurusan Kedokteran",
              array(
                  "Prodi Pendidikan Dokter"
              )
          ),
          array(
              "Jurusan Keperawatan dan Gizi",
              array(
                  "Prodi Ilmu Keperawatan",
                  "Prodi Ilmu Gizi",
                  "Prodi Farmasi",
                  "Prodi Kebidanan"
              )
          )
      )   
  );  
  ?&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;th&gt;Fakultas&lt;/th&gt;
          &lt;th&gt;Jurusan&lt;/th&gt;
          &lt;th&gt;Program Studi&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the result must be like this:<br>
  <a href="https://i.stack.imgur.com/0vjCi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0vjCi.png" alt="enter image description here"></a></p>
  
  <p>What should I do to make a table like this? I have tried this, but it doesn't work:</p>
  
  <pre><code>for($baris = 0 ; $baris &lt; 2 ; $baris++ ) {
      echo $ub[$baris][0] ; $baris++;} ?&gt;
      &lt;/th&gt;
      &lt;th&gt;
      &lt;?php 
      for($barisa = 0 ; $barisa &lt; 2 ; $barisa++ ) {
          echo $ub[$barisa+1][1];
          $barisa++;
      }
      ?&gt;
      &lt;/th&gt;
      &lt;th&gt;
      &lt;?php 
      for($barisb = 0 ; $barisb &lt; 4 ; $barisb++ ) {
          echo $ub[$barisb+1][2] ;
          $barisb++;
      }
      ?&gt;
      &lt;/th&gt;
  </code></pre>
  
  <p>Thank you.</p>