i have two tables which i attached. user can add N level question answers. i am using CI.
i am using this code for generating ul li. and my array which fetch result set is like this.... but not working ...
for working ul li function i have to pass this array. so how to convert$tree = array('A', 'B', 'C' => array('CA', 'CB'), 'D');
Array
(
[0] => Array
(
[pkQMainAnsId] => 5
[parent_id] => 0
[QuestionAnswerText] => This is i am gussing my favor
[AnswerOption] => Sooby
)
[1] => Array
(
[pkQMainAnsId] => 6
[parent_id] => 0
[QuestionAnswerText] => This is i am gussing my favor
[AnswerOption] => dooby
)
[2] => Array
(
[pkQMainAnsId] => 7
[parent_id] => 0
[QuestionAnswerText] => This is i am gussing my favor
[AnswerOption] => zoooby
)
[3] => Array
(
[pkQMainAnsId] => 8
[parent_id] => 0
[QuestionAnswerText] => This my favo hero
[AnswerOption] => Davidw
)
[4] => Array
(
[pkQMainAnsId] => 9
[parent_id] => 0
[QuestionAnswerText] => This my favo hero
[AnswerOption] => shavida
)
)
public function olLiTree($tree) {
$out = '<ul id="tree" class="treeview">';
foreach($tree as $key => $value) {
$out.= '<li>';
if (is_array($value)) {
$out.= $key . $this->olLiTree($value);
} else {
$out.= $value;
}
$out.= '</li>';
}
$out.= '</ul>';
return $out;
}