Skip to content

Instantly share code, notes, and snippets.

@chucktrukk
Created February 11, 2010 03:04
Show Gist options
  • Save chucktrukk/301161 to your computer and use it in GitHub Desktop.
Save chucktrukk/301161 to your computer and use it in GitHub Desktop.
<?php
$numbers = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
$grid = array_chunk($numbers, 4);
$output = '';
foreach($grid as $row)
{
$output[] = '<tr>'; //or ul
foreach($row as $item)
{
$output[] = '<td>'.$item.'</td>';
}
$output[] = '</tr>'; //or ul
}
echo implode($output, '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment