I have the following PHP array.
Array
(
[168] => Array
(
[link] => asdfasdf
[children] => Array
(
[239] => Array
(
[link] => tascatestlalal
[children] => Array
(
)
)
[240] => Array
(
[link] => otrotestttt
[children] => Array
(
)
)
)
)
[229] => Array
(
[link] => Sub-task ex
[children] => Array
(
)
)
[230] => Array
(
[link] => Sub-task test
[children] => Array
(
[231] => Array
(
[link] => tasktest1
[children] => Array
(
)
)
[232] => Array
(
[link] => tasktest 2
[children] => Array
(
[233] => Array
(
[link] => tasktest 5
[children] => Array
(
[235] => Array
(
[link] => tasca235
[children] => Array
(
)
)
)
)
)
)
[234] => Array
(
[link] => tasca234
[children] => Array
(
)
)
)
)
)
and I need to convert it into this
<table>
<tr>
<td>
Sub-task
</td>
</tr>
<tr>
<td>
--Tasktest1
</td>
</tr>
<tr>
<td>
--tasktest 2
</td>
</tr>
<tr>
<td>
---tasktest 5
</td>
</tr>
<tr>
<td>
----tasca235
</td>
</tr>
<tr>
<td>
--tasca234
</td>
</tr>
</table>
this I already know how to do it with a list with this function, but cant seen to modify this function to transform it into the table example above :( . some help will be greatly appreciated
function ArrayToHTMLList($arr) {
$str = "<ul class='tasklist'>";
foreach($arr as $key => $value) {
if((!empty($value))){
$str .="<li>";
if(is_array($value))
$str .= ArrayToHTMLList($value);
else
$str .= $value;
$str .= "</li>";
}
}
$str .= "</ul>";
return $str;
}