I understand that you need to unravel the news inside the table - <table>
$news = array( 'Новость 1', 'Новость 2', 'Новость 3', 'Новость 4', 'Новость 5', 'Новость 6', 'Новость 7', 'Новость 8', 'Новость 9', 'Новость 10', 'Новость 11' ); $newsArr = array_chunk(array_reverse($news),5); $tbl = '<table border="1"><tr>'; for($i = 0; $i < 5; $i++){ for($k = 0; $k < count($newsArr); $k++){ $tbl .= '<td>'.$newsArr[$k][$i].'</td>'; } $tbl .= '</tr><tr>'; } $tbl .= '</tr></table>'; echo $tbl;
PS Function array_reverse () to you, I think that is not needed, because you pull out records from a DB already with DESC sorting.
And I forgot to add that for the purity of the process, you can “align” the size of the array, where the elements will be less than five, but this is up to you. In general, in the end, we get here such cakes with kittens . (clicking on the link, press F9 )