Split links into multiple columns

I currently have a drop down menu which displays categories, but i want them to display in equal columns horizontally.

How could I do that using PHP?

This is what I have:

<div id="menu" class="grid_12">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div class="sixth_color_border">
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo  $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <div class="categories_spacer"></div>
    <?php } ?>
  </ul>
</div>

Any ideas?
Thanks

You could use a table instead of a ul.

This is done using html and css and has nothing to do with php.

What you need to do is style each li to ‘display: inline;’ for the items you want to be horizontal. Also styling them to ‘list-style-type: none;’ will remove the circles / squares that are used in the list.

This would be the css:


ul li {
    display: inline;
    list-style-type: none;
}