What is the most efficient way to output the users in the format below:
Vinny,Blue|Red
Mike,Blue
LeeRoy,Blue
Jenny,Blue|Red
Deborah,Red
Using the following code:
<Section1 name="colors" category="colors">
<Section2 name="Blue" category="color">
<Section3 name="Users" category="users">
<Section4 name="Vinny" category="user"></Section4>
<Section4 name="Mike" category="user"></Section4>
<Section4 name="LeeRoy" category="user"></Section4>
<Section4 name="Jenny" category="user"></Section4>
</Section3>
</Section2>
<Section2 name="Red" category="color">
<Section3 name="Users" category="users">
<Section4 name="Vinny" category="user"></Section4>
<Section4 name="Jenny" category="user"></Section4>
<Section4 name="Deborah" category="user"></Section4>
</Section3>
</Section2>
</Section1>
With the condition that if the users (Section4) appear in multiple colors (Section 2), they are separated by the | character.
At first I dumped all the colors in one array, then was going to dump all the users in another array, then I got stuck trying to do a couple of things...