title: creating one array out of multiple arrays and concatenating unique values in a certain key
body: <p>I need to loop through a bunch of arrays that I am getting back from mysql that contain a lot of duplicate entries and create one array out of several. The arrays will have one or more unique values in them so I need to keep these but some how concatenate them together into one string using commas or semicolons. So far I am not having any luck with this. Here is a <a href="http://phpfiddle.org/main/code/9dz-rm0" rel="nofollow">phpfiddle</a></p>
  
  <p>I need it to create a single array like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; test
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; one
              [4] =&gt; two
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; test1
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; three
              [4] =&gt; four
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; test2
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; five, seven
              [4] =&gt; six, eight
          )
  
      [3] =&gt; Array
          (
              [0] =&gt; test3
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; nine
              [4] =&gt; ten
          )
  
  )
  </code></pre>
  
  <p>from an array like this</p>
  
  <pre><code>    Array
  (
      [0] =&gt; Array
          (
              [0] =&gt; test
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; one
              [4] =&gt; two
          )
  
      [1] =&gt; Array
          (
              [0] =&gt; test1
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; three
              [4] =&gt; four
          )
  
      [2] =&gt; Array
          (
              [0] =&gt; test2
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; five
              [4] =&gt; six
          )
  
      [3] =&gt; Array
          (
              [0] =&gt; test2
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; seven
              [4] =&gt; eight
          )
  
      [4] =&gt; Array
          (
              [0] =&gt; test3
              [1] =&gt; test
              [2] =&gt; test
              [3] =&gt; nine
              [4] =&gt; ten
          )
  
  )
  </code></pre>
  
  <p>this is what I am trying:</p>
  
  <pre><code>for($i=0; $i &lt; count($arrayBIG); $i++) {
      if($arrayBIG[$i][0] == $arrayBIG[$i+1][0]) {
          $clean[$i] = array(array_unique(array_merge($arrayBIG[$i],$arrayBIG[$i+1]), SORT_REGULAR));
      }
  }
  </code></pre>