I have a database that looks like this:

I can generate a tree from this menu using the following code:
foreach($categories->result_array() as $category):
$menu_array[$category['id']] = array('name' => $category['name'], 'parent' => $category['parent'], 'id' => $category['id']);
endforeach;
echo '<ul>';
echo $this->tasks->generateCategoriesTree(NULL, $menu_array);
echo '</ul>';
And here’s the function the above code calls:
function generateCategoriesTree($parent, $menu_array, $result = NULL)
{
foreach($menu_array as $key => $value):
if ($value['parent'] == $parent):
$result .= '<li>';
$result .= '<a href="#">' . $value['name'] . '</a>';
$result .= '<ul>';
$result .= $this->generateCategoriesTree($key, $menu_array);
$result .= '</li></ul>';
endif;
endforeach;
return $result;
}
It generates a tree that looks like this:

My problem now is getting the parent category to be bold. In my database, row’s that are parents have the parent column as NULL. I’ve tried a couple things, such as a if ($value['parent'] !== $parent) then applying a bold style, but that doesn’t work. I honestly cannot wrap my head around this. I would appreciate any help you guys can provide!
I would make it bold if the parent is equal to NULL. I’m not sure about the use of the syntax since I normally use parentheses for if-structures.
You would have to use some styling to make the class BOLDCLASS bold of course.