title: how to remove subarray with a common element to another subarray in php
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/307674/how-to-remove-duplicate-values-from-a-multi-dimensional-array-in-php">How to remove duplicate values from a multi-dimensional array in PHP</a>  </p>
  </blockquote>
  
  
  
  <p>Sorry for writing this too fast, I was working..., sorry. Now I think is good explained.I want remove subarrays with the subelement [title] common, equals, I want only one element, not repetitions,  how can I do that?. I made it, but I think must be a way more elegante to make it. I tried with this code:</p>
  
  <pre><code>static function remove_duplicates_titles($deals){
         $result = array();
         $deal_repeated=false;
         foreach ($deals as $index=&gt;$deal) {
             foreach ($deals as $deal_2) {
                 //discover if the subarray has the element title repeated is repeated or not
                 if ($deal['title'] == $deal_2['title']){ 
                      $deal_repeated=true;
                      unset($deal_2);  
                 }
                 else{ 
                      $deal_repeated=false;                          
                  }
  
             }
            //if the array has no the element (title) repeated with another....
            if(!$deal_repeated){
                     $result[]=$deal;
             }
         }
  
         return $result;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [id] =&gt; abc
          [title] =&gt; bbb
      )
  
  [1] =&gt; Array
      (
          [id] =&gt; ghi
          [title] =&gt; aaa
      )
  
  [2] =&gt; Array              //I should to remove this subarray (or the other, only one of both)
      (
          [id] =&gt; mno
          [title] =&gt; pql     //this is common
      )
  
  [3] =&gt; Array
      (
          [id] =&gt; abc
          [title] =&gt; def
      )
  
  [4] =&gt; Array
      (
          [id] =&gt; ghi
          [title] =&gt; mmm
      )
  
  [5] =&gt; Array             //I should to remove this subarray (or the other), only one of both
      (
          [id] =&gt; mno
          [title] =&gt; pql   //this is common
      )
  </code></pre>
  
  <p>)</p>