title: Remove duplicates in MultiDimensional array and keep the original array key value
body: <p>I have this array </p>
  
  <pre><code>Array (
      [0] =&gt; Array ( [name] =&gt; Apple [amount] =&gt; 1)
      [1] =&gt; Array ( [name] =&gt; Apple [amount] =&gt; 2)
      [2] =&gt; Array ( [name] =&gt; Orange [amount] =&gt; 3)
      [3] =&gt; Array ( [name] =&gt; Orange [amount] =&gt; 4)
      [4] =&gt; Array ( [name] =&gt; Banana [amount] =&gt; 5)
      [5] =&gt; Array ( [name] =&gt; Pear [amount] =&gt; 6)
  )
  </code></pre>
  
  <p>Which I would like to end up like this:</p>
  
  <pre><code>Array (
      [0] =&gt; Array ( [name] =&gt; Apple [amount] =&gt; 1)
      [2] =&gt; Array ( [name] =&gt; Orange [amount] =&gt; 3)
      [4] =&gt; Array ( [name] =&gt; Banana [amount] =&gt; 5)
      [5] =&gt; Array ( [name] =&gt; Pear [amount] =&gt; 6)
  )
  </code></pre>
  
  <p>The important thing is that the array key values must be the same after transforming.</p>
  
  <p>At the moment I use this solution:</p>
  
  <pre><code>$newArray = array();
  $usedFruits = array();
  
  foreach ( $originalArray AS $line ) {
      if ( !in_array($line['name'], $usedFruits) ) {
          $usedFruits[] = $line['name'];
          $newArray[] = $line;
      }
  }
  
  $originalArray = $newArray;
  $newArray = NULL;
  $usedFruits = NULL;
  </code></pre>
  
  <p>This removes the duplicate arrays but it also resets the key values. </p>
  
  <pre><code>Array ( 
      [0] =&gt; Array ( [name] =&gt; Apple [amount] =&gt; 1)
      [1] =&gt; Array ( [name] =&gt; Orange [amount] =&gt; 3)
      [2] =&gt; Array ( [name] =&gt; Banana [amount] =&gt; 5)
      [3] =&gt; Array ( [name] =&gt; Pear [amount] =&gt; 6)
  )
  </code></pre>
  
  <p>How is it possible to keep the original array key values?</p>