Populate php array into HTML table
I have data in a php array (say, $rows2) that gives the below output in key-value pairs. I am trying to format this data into an HTML table:
0 => Month:
1 => 07/2011,
2 => 7-8
3 => / 1432 A.H
4 =>
5 => Location:
6 => Plainfield,
7 => NJ,
8 => USA
9 => Calculation Method:
10 => Value 10
11 =>
12 => Juristic Method:
13 => Standard
I tried to use the below code to populate the table:
echo '<table border=1>';
while (list($key, $value) = each($rows2)) {
echo $value2.$value;
if($i%5 == 0){
echo '<tr><td>'.$value2.'</td></tr>';
}
$value2='';
$i++;
}
echo '</table>';
I get the below output:
--------------------------------------------------------
Month: | 07/2011 | 7-8 | 1432 A.H
--------------------------------------------------------
Location: | Plainfield | NJ | USA
--------------------------------------------------------
Calculation | ValueX | Juristic | ValueY
Method: | | Method: |
--------------------------------------------------------
I am trying to split the last row into 2 rows and then colspan the second to look like the below result.
--------------------------------------------------------
Month: | 07/2011 | 7-8 | 1432 A.H
--------------------------------------------------------
Location: | Plainfield | NJ | USA
--------------------------------------------------------
Calculation | ValueX
Method: |
--------------------------------------------------------
Juristic | ValueY
Method: |
--------------------------------------------------------
Could someone please help? Thanks in advance.