Last active
December 17, 2015 01:29
-
-
Save halgatewood/5528331 to your computer and use it in GitHub Desktop.
Convert an array of objects into rows of arrayed objects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More information: http://halgatewood.com/php-function-make-rows/