I can output data to a string or an array like following. And I know the number of columns and rows. For example $numofrow is 6 and max $numofcol is 5 for this data.
Now what I am not sure is that how I can these to a table. Should I use the array? If so, how? Problem is that some rows have less number of data or td than others.
//as an array $mycriteria
array(6) {
[0]=>
string(64) "Criteron A-1,Criteron A-2,Criteron A-3,Criteron A-4,Criteron A-5"
[1]=>
string(64) "Criteron B-1,Criteron B-2,Criteron B-3,Criteron B-4,Criteron B-5"
[2]=>
string(51) "Criteron C-1,Criteron C-2,Criteron C-3,Criteron C-4"
[3]=>
string(38) "Criteron D-1,Criteron D-2,Criteron D-3"
[4]=>
string(64) "Criteron E-1,Criteron E-2,Criteron E-3,Criteron E-4,Criteron E-5"
[5]=>
string(51) "Criteron F-1,Criteron F-2,Criteron F-3,Criteron F-4"
}
//as a string $mycriteria
mycriteria: string(337) "Criteron A-1,Criteron A-2,Criteron A-3,Criteron A-4,Criteron A-5
Criteron B-1,Criteron B-2,Criteron B-3,Criteron B-4,Criteron B-5
Criteron C-1,Criteron C-2,Criteron C-3,Criteron C-4
Criteron D-1,Criteron D-2,Criteron D-3
Criteron E-1,Criteron E-2,Criteron E-3,Criteron E-4,Criteron E-5
Criteron F-1,Criteron F-2,Criteron F-3,Criteron F-4"
Update:
I really need to have empty td as you see below since I am using border lines. Without empty td, it looks ugly.
What I am looking for is the following HTML.
<table>
<tr>
<td>Criteron A-1</td><td>Criteron A-2</td><td>Criteron A-3</td><td>Criteron A-4</td><td>Criteron A-5</td>
</tr>
...
<tr>
<td>Criteron D-1</td><td>Criteron D-2</td><td>Criteron D-3</td><td></td><td></td>
</tr>
...
</table>
Since you want full rows, here’s another answer with that:
Required PHP 5.3. If you have lower replace the first line with: