The PEAR::HTML_TreeMenu PHP package provides methods for HTML tree menus.

PHP Based api creates a tree structure using a couple of small PHP classes.
This can then be converted to javascript using the printMenu() method.  The
tree is dynamic in IE 4 or higher, NN6/Mozilla and Opera 7, and maintains state
(the collapsed/expanded status of the branches) by using cookies.
Other browsers display the tree fully expanded.  Each node can have an
optional link and icon.

Homepage:
https://pear.php.net/package/HTML_TreeMenu
