$html = "\n\n"; array_pop($stack); } $html .= "
  • ".$cat['cat_name']; #if the category has no children, close the list item. if($cat['lft']+1==$cat['rgt']) { $html .= "
  • \n"; #category has children, start a list...add the "parent"'s right value to the stack } else { $html .= "\n\n"; array_pop($stack); } $html .= "";