title: Removing Repeating Id Values from 2D array : PHP
body: <p>I have an array like </p>
  
  <pre><code>$a = array(
      array('id'=&gt;1, 'value'=&gt;2),
      array('id'=&gt;2, 'value'=&gt;3),
      array('id'=&gt;3, 'value'=&gt;4),
      array('id'=&gt;1, 'value'=&gt;5),
      array('id'=&gt;5, 'value'=&gt;10),
      array('id'=&gt;2, 'value'=&gt;6),
  
  );
  </code></pre>
  
  <p>from this i want an array which don't have the repeating id wise keys value
  e.g</p>
  
  <pre><code>$a = array(
      array('id'=&gt;3, 'value'=&gt;4),
      array('id'=&gt;1, 'value'=&gt;5),
      array('id'=&gt;5, 'value'=&gt;10),
      array('id'=&gt;2, 'value'=&gt;6)
  );
  </code></pre>
  
  <p>i tried the following one but unable to get final result.</p>
  
  <pre><code>$i=0;
      foreach ($a as $key=&gt;$value) {
          // $arr[$i] = $value;
          foreach ($a as $key1=&gt;$value1) {
              if(!empty(array_diff($value, $value1))) {
                  if( $value['id'] == $value1['id'] ) {
                      $arr[$i]=$value1;
                  }
                  else {
                      $arr[$i]=$value;
                  }
              }
          }
          $i++;
      }
  </code></pre>