I am trying to figure out why I am getting this error notice, Does anyone have an idea as to why this is
happening.
Notice: Undefined offset: 5
on line: if ($tree[$i]['level'] < $tree[$i+1]['level']) {
on line: } elseif ($tree[$i]['level'] == $tree[$i+1]['level']) {
on line: $diff = $tree[$i]['level'] - $tree[$i+1]['level'];
public function treeAsHtml() {
$tree = $this->getTree();
$html = "<ul>\n";
for ($i=0; $i<count($tree); $i++) {
$html .= "<li>" . $tree[$i][$this->name];
if ($tree[$i]['level'] < $tree[$i+1]['level']) {
$html .= "\n<ul>\n";
} elseif ($tree[$i]['level'] == $tree[$i+1]['level']) {
$html .= "</li>\n";
} else {
$diff = $tree[$i]['level'] - $tree[$i+1]['level'];
$html .= str_repeat("</li>\n</ul>\n", $diff) . "</li>\n";
}
}
$html .= "</ul>\n";
return $html;
}