Created
November 28, 2016 10:49
-
-
Save abdeltiflouardi/b911a17ad9252985dcff1ed5ee08c44e to your computer and use it in GitHub Desktop.
Columns
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
<?php | |
$list = array(1,2,2,2,2,3,3,1,1,1,1,1,2,2,1,2,3,1,2,1,1,3); | |
$line = 1; | |
$ordered = array(); | |
foreach ($list as $item) { | |
if (isset($ordered[$line]) && (array_sum($ordered[$line]) + $item) > 3) { | |
$line++; | |
} | |
$ordered[$line][] = $item; | |
} | |
var_dump($ordered); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment