title: Find duplicates in array of objects on the basis of specific keys
body: <p>my goal is to find duplicates in an array of objects, but only for specific object-variables.</p>
  
  <p>Instead of using two foreach-loops like the following, I am searching for a better (more elegant) way to find the duplicates:</p>
  
  <pre><code>foreach ($data as $date) {
        foreach ($data as $innerDate) {
            if ($date-&gt;birthday == $innerDate-&gt;birthday &amp;&amp;
                $date-&gt;street == $innerDate-&gt;street &amp;&amp;
                $date-&gt;streetnr == $innerDate-&gt;streetnr &amp;&amp;
                $date-&gt;zipcode == $innerDate-&gt;zipcode &amp;&amp;
                $date-&gt;twinid == $innerDate-&gt;twinid &amp;&amp;
                $date !== $innerDate) {
                // Duple
          }
      }
  }
  </code></pre>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>Now, I'm using following code, based on Tarilo's idea:</p>
  
  <pre><code>usort($data, function($obj_a, $obj_b){
        if ($obj_a-&gt;birthday == $obj_b-&gt;birthday &amp;&amp;
            $obj_a-&gt;street == $obj_b-&gt;street &amp;&amp;
            $obj_a-&gt;streetnr == $obj_b-&gt;streetnr &amp;&amp;
            $obj_a-&gt;zipcode == $obj_b-&gt;zipcode &amp;&amp;
            $obj_a-&gt;twinid == $obj_b-&gt;twinid) {
            // Duple
        }
  });
  </code></pre>
  
  <p>Looks much better than two foreach-Loops ;-)</p>