Skip to content

Instantly share code, notes, and snippets.

@halgatewood
Last active December 17, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halgatewood/5528331 to your computer and use it in GitHub Desktop.
Save halgatewood/5528331 to your computer and use it in GitHub Desktop.
Convert an array of objects into rows of arrayed objects.
function make_rows($array, $per = 4)
{
$rows = array();
$c = 1;
$row = 0;
foreach($array as $item)
{
$rows[ $row ][] = $item;
if($c == $per) { $row++; $c = 0; }
$c++;
}
return $rows;
}
@halgatewood
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment