I have a bunch of elements for a navigation panel in an array like so:
Labs
Labs_RH1557
Mission_Statement
Labs_CLB702
Wireless
Wirelsss_Intel
About_Us
My question is: what would be the most efficient way to transform into an unordered list like so:
* About Us
* Labs
- CLB702
- RH1557
* Mission Statement
* Wireless
- Intel
(wherein all elements with more than one string in common before the _ are grouped under the heading)
My current strategy is to loop through the array and split by _'s. Then create another array with only unique elements, then go through again and add in items that should go under them.
Haven't written any code yet.
Thanks!