public function testTransform() { $input = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; $this->assertSame(Data::transform($input), [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); }
private function column($rows) { $cols = Data::transform($rows); $lens = array_map(function ($col) { return max(array_map('strlen', $col)); }, $cols); return array_map(function ($row) use($lens) { return implode("\t", array_map('str_pad', $row, $lens)); }, $rows); }