I have a textarea which I am inputting data into to put it into a format that I need. The data that I am inputting looks like this:

POTTERTON PUMA 80 E (SIT/HONEYWELL) (ALL PARTS FOR THIS MODEL)  

POTTERTON PUMA 80 E (SIT/HONEYWELL) (FRAME - PIPEWORK)  

POTTERTON TATTLER KINGFISHER RS 46 (ALL PARTS FOR THIS MODEL)  

POTTERTON PUMA 100 E (SIT/HONEYWELL (ALL PARTS FOR THIS MODEL)  

POTTERTON PUMA 100 E (SIT/HONEYWELL (FRAME - PIPEWORK)

Sometimes there are two sets of brackets, sometimes there is one and sometimes there is one unclosed bracket and then another set at the end. So once the data is processed it should look like this:

POTTERTON PUMA 80 E (SIT/HONEYWELL),POTTERTON TATTLER KINGFISHER RS 46,POTTERTON PUMA 100 E (SIT/HONEYWELL

So I basically want the repeat occurances removed and the last brackets removed. The code that I have written does the job for most of the data, but removes all of the brackets.

This is my code:

```
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
?>
<form action="<?php the_permalink(); ?>" method="post">
    <textarea style="width:1000px;height:350px;" name="like"></textarea>
    <button>Submit</button>
</form>
<?php
} else {
    $fits = $_POST['like'];
    $fits = str_replace(" (","(",$fits);
    $fits = preg_replace("/\([^\)]+\)/","", $fits);
    $fits = explode("\n", str_replace("\r", "", $fits));
    $fits = array_unique($fits);
    $comma_separated = implode(', ', $fits);
    echo $comma_separated;
}
?>

```