Good day.
Am displaying array in five columns and I need to push value to the last if values having specified key arrived at last.
<?php
$say = array("1","2","3","4","m"=>"5","s"=>"6","7","8","9","10","11","12");
$columns = 5;
for ($p=0; $p <count($say); $p++) {
if ($p==0) {
print "<table><tr>";
} elseif ($p%$columns == 0) {
print "<tr>";
}
print "<td>".htmlspecialchars($say[$p])."</td>";
if (($p+1)%$columns == 0) {
print "</tr>";
}
if ($p==count($say)-1) {
$empty = $columns - (count($say)%$columns) ;
if ($empty != $columns) {
print "<td colspan=$empty> </td>";
}
print "</tr></table>";
}
}
?>
I used this code to display in five columns