<?php $arrayTable = [ [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], ]; $i = 0; $transpose = []; while ($columns = array_column($arrayTable, $i++)) { $transpose[] = $columns; } $table = '<table border="1">'; $rows = count($transpose); for ($i = 0; $i < $rows; $i++){ $cols = count($transpose[$i]); $table .= '<tr>'; for ($j = 0; $j < $cols; $j++) { $table .= '<td>' . $transpose[$i][$j] . '</td>'; } $table .= '</tr>'; } $table .= '</table>'; echo $table;
You have javascript disabled. You will not be able to edit any code.