title: find duplicate value in multidimensional array and combine their ID in comma separated with accordingly using PHP
body: <p>I have multidimensional array which listed in dynamically call from the database where need to have apply filter on conditional base of unique <code>value</code> and their <code>ID</code> merge with comma separated accordingly as with below desired result.</p>
  
  <pre><code>$arr = array();
  
  $arr[0]['attribute'] = 'A';
  $arr[0]['value'] = array('tenghao','Yuncheng','TAIFENG','Xinsheng','Laiwu Wanxin');
  $arr[0]['ID'] = array(3561,3568,3560,3567,3569);
  
  $arr[1]['attribute'] = 'B';
  $arr[1]['value'] = array('Red, Red','Red','Red','Red','Red', 'Red');    
  $arr[1]['ID'] = array(3567,3569,3561,3568,3569,3560);
  
  $arr[2]['attribute'] = 'C';
  $arr[2]['value'] = array("90%","80%","80%-100%","90%","100%");    
  $arr[2]['ID'] = array(3567,3569,3561,3568,3560);
  </code></pre>
  
  <p><strong>Desired Result</strong></p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [attribute] =&gt; A
              [value] =&gt; Array
                  (
                      [0] =&gt; tenghao
                      [1] =&gt; Yuncheng
                      [2] =&gt; TAIFENG
                      [3] =&gt; Xinsheng
                      [4] =&gt; Laiwu Wanxin
                  )
  
              [ID] =&gt; Array
                  (
                      [0] =&gt; 3561
                      [1] =&gt; 3568
                      [2] =&gt; 3560
                      [3] =&gt; 3567
                      [4] =&gt; 3569
                  )
  
          )
  
      [1] =&gt; Array
          (
              [attribute] =&gt; B
              [value] =&gt; Array
                  (
                      [0] =&gt; Red, Red
                      [1] =&gt; Red
                  )
  
              [ID] =&gt; Array
                  (
                      [0] =&gt; 3567
                      [1] =&gt; 3569,3561,3568,3569,3560
                  )
  
          )
  
      [2] =&gt; Array
          (
              [attribute] =&gt; C
              [value] =&gt; Array
                  (
                      [0] =&gt; 90%
                      [1] =&gt; 80%
                      [2] =&gt; 80%-100%
                      [3] =&gt; 100%
                  )
  
              [ID] =&gt; Array
                  (
                      [0] =&gt; 3567,3568
                      [1] =&gt; 3569
                      [2] =&gt; 3561
                      [3] =&gt; 3560
                  )
  
          )
  
  )
  </code></pre>