Skip to content

Instantly share code, notes, and snippets.

@artofhuman
Created April 21, 2013 16:44
Show Gist options
  • Select an option

  • Save artofhuman/5430217 to your computer and use it in GitHub Desktop.

Select an option

Save artofhuman/5430217 to your computer and use it in GitHub Desktop.
/*
* Разбивает массив на колонки
*/
function array_split($array, $pieces=2)
{
if ($pieces < 2)
return array($array);
$newCount = ceil(count($array)/$pieces);
$a = array_slice($array, 0, $newCount);
$b = array_split(array_slice($array, $newCount), $pieces-1);
return array_merge(array($a),$b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment