<?php $input = ['A', 'B', 'C', 'D', 'E', 'F', 'G']; $cols = 2; $rows = ceil(count($input) / $cols); $result = []; foreach ($input as $i => $value) { $result[$i % $rows][] = $value; } var_export($result);
You have javascript disabled. You will not be able to edit any code.