I've an array like this:
Array
(
[0] => Array
(
[0] => Array
(
[0] => Array
(
[0] => a
[1] => d
[2] => Array(...)
)
)
)
[1] => Array
(
[0] => Array
(
[0] => Array
(
[0] => a
[1] => e
[2] => Array(...)
)
)
)
)
I would like to create, from this array, an set of checkbox nested in HTML <li>
statement.
I've created a function for make the nested <li>
function nested_li(array $array){
$output = '<ul>';
foreach($array as $key => $value){
$output .= "<li><strong>$key: </strong>
";
if(is_array($value)){
$output .= nested_li($value)."
";
}else{
$output .= $value."
";
}
$output .= '</li>'."
";
}
$output .= '</ul>'."
";
return $output;
}
Now the trouble is to create in this a nested checkbox list, for example:
<input type="checkbox" name="check[0][0][0][0]" value="a"/>
<input type="checkbox" name="check[0][0][0][1]" value="d"/>
<input type="checkbox" name="check[1][0][0][0]" value="a"/>
<input type="checkbox" name="check[1][0][0][1]" value="e"/>
I need to do this for a category system, for choose what category to display.