<?php
$arrayTable = [
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
];
$i = 0;
$transpose = [];
while ($columns = array_column($arrayTable, $i++))
{
$transpose[] = $columns;
}
$rows = count($transpose);
for ($i = 0; $i < $rows; $i++){
$cols = count($transpose[$i]);
for ($j = 0; $j < $cols; $j++)
{
$table .= $transpose[$i][$j] . ',';
}
}
echo $table;
preferences:
27.99 ms | 402 KiB | 5 Q