title: How to display a list in three columns using php?
body: <p>For the past couple of hours, I've been unsuccessfully trying to figure out the php code to display a list in three columns so that it has this order</p>
  
  <pre><code>A D G
  B E H
  C F I
  </code></pre>
  
  <p>but I'm really lost. Can anyone help me with this?
  I currently only have code that lists in this order</p>
  
  <pre><code>A B C
  D E F
  G H I
  </code></pre>
  
  <p>This is my current code:</p>
  
  <pre><code>echo '&lt;table&gt;&lt;tr&gt;';
  foreach ($categories as $k =&gt; $category) {
      if ($k % 3 == 0 &amp;&amp; $k ! = 0) {
          echo '&lt;/tr&gt;&lt;tr&gt;';
      }
      echo '&lt;td&gt;&lt;a href="category.php?category='.$category["id"].'"&gt;'.$category["category"].'&lt;/a&gt;&lt;/td&gt;';
  }
  echo '&lt;/table&gt;';
  </code></pre>