I have some data in this format:

```
even--heaped<br />
even--trees<br />
hardrocks-cocked<br />
pebble-temple<br />
heaped-feast<br />
trees-feast<br />

```

and I want to end up with an output so that all lines with the same words get added to each other with no repeats.

```
even--heaped--trees--feast<br />
hardrocks--cocked<br />
pebbles-temple<br />

```

i tried a loop going through both arrays but its not the exact result I want. for an array $thing:

```
Array ( [0] => even--heaped [1] => even--trees [2] => hardrocks--cocked [3] => pebbles--temple [4] => heaped--feast [5] => trees--feast )

for ($i=0;$i<count($thing);$i++){
    for ($j=$i+1;$j<count($thing);$j++){
        $first = explode("--",$thing[$i]);
        $second = explode("--",$thing[$j]);

        $merge = array_merge($first,$second);
        $unique = array_unique($merge);

    if (count($unique)==3){
        $fix = implode("--",$unique);
        $out[$i] = $thing[$i]."--".$thing[$j];
    }

}

}

print_r($out);

```

but the result is:

```
Array ( [0] => even--heaped--heaped--feast [1] => even--trees--trees--feast [4] => heaped--feast--trees--feast )

```

which is not what i want. Any suggestions (sorry about the terrible `variable names`).