title: How to merge two arrays without duplicate values in php?
body: <p>I have two arrays:
  1. each object here is a row retrived from database.</p>
  
  <pre><code>    array
        1 =&gt; 
          object(stdClass)[41]
            public 'id' =&gt; string '1' (length=1)
            public 'class_id' =&gt; string '25' (length=2)
            public 'section_id' =&gt; string '2' (length=1)
            public 'student_id' =&gt; string '1' (length=1)
            public 'date' =&gt; string '2011-11-27' (length=10)
            public 'attendance' =&gt; string 'present' (length=7)
  2 =&gt; 
          object(stdClass)[41]
            public 'id' =&gt; string '1' (length=1)
            public 'class_id' =&gt; string '25' (length=2)
            public 'section_id' =&gt; string '2' (length=1)
            public 'student_id' =&gt; string '3' (length=1)
            public 'date' =&gt; string '2011-11-27' (length=10)
            public 'attendance' =&gt; string 'present' (length=7)
  </code></pre>
  
  <p>2. Another array is from my form and this looks like this.</p>
  
  <pre><code>array
    0 =&gt; 
      array
        'class_id' =&gt; string '25' (length=2)
        'section_id' =&gt; string '2' (length=1)
        'student_id' =&gt; int 1
        'date' =&gt; string '2011-11-27 00:00:00' (length=19)
        'attendance' =&gt; string 'present' (length=7)
    1 =&gt; 
      array
        'class_id' =&gt; string '25' (length=2)
        'section_id' =&gt; string '2' (length=1)
        'student_id' =&gt; int 2
        'date' =&gt; string '2011-11-27 00:00:00' (length=19)
        'attendance' =&gt; string 'present' (length=7)
  </code></pre>
  
  <p>Here what I want to do is:<br>
  - compare these two and check if key student_id and date are already on database or not.<br>
  - and from second array which is from form data, remove duplicate and insert into data.<br>
  The final result should be: <br></p>
  
  <pre><code>array
    0 =&gt; 
      array
        'class_id' =&gt; string '25' (length=2)
        'section_id' =&gt; string '2' (length=1)
        'student_id' =&gt; int 2
        'date' =&gt; string '2011-11-27 00:00:00' (length=19)
        'attendance' =&gt; string 'present' (length=7)
  </code></pre>