I need to extract data from a multidimensional array
array(2) {
["label"]=>
string(6) "label1"
["children"]=>
array(3) {
[1]=>
array(1) {
["label"]=>
string(6) "label2"
}
[2]=>
array(1) {
["label"]=>
string(6) "label3"
}
[3]=>
array(2) {
["label"]=>
string(6) "label4"
["children"]=>
array(2) {
[1]=>
array(1) {
["label"]=>
string(6) "label5"
}
[2]=>
array(1) {
["label"]=>
string(6) "label6"
}
}
}
}
}
into a table with the following structure:
<table border="1">
<tr>
<td colspan="4">label1</td>
</tr>
<tr>
<td colspan="1">label2</td>
<td colspan="1">label3</td>
<td colspan="2">label4</td>
</tr>
<tr>
<td></td>
<td></td>
<td colspan="1">label5</td>
<td colspan="1">label6</td>
</tr>
</table>
The depth and structure of the array are dynamic, but the basic rule stays the same.
Any ideea on how I may accomplish this? Thank you!