title: PHP remove duplicates in a large array
body: <p>I was removing duplicates from an array, i have used  <code>array_unique($array)</code>,</p>
  <p>here an example for the array i tested on: <code>[7 6 4 3 3 4 9]</code>.</p>
  <pre><code>'the initial order of the values must be kept' 
  </code></pre>
  <p>Here's my Function:</p>
  <pre><code> function rmrepeat ($array) {
      $array2 = array_unique($array); 
      return $array2; 
   } 
   // Input Array 
   $a=array(7, 6, 4, 3, 3, 4, 9); 
   $newArray = rmrepeat($a);
  </code></pre>
  <h2>Then i got 2 main errors:</h2>
  <blockquote>
  <ul>
  <li><p>when i tested it on an array with 299 elements it didnt work.</p>
  </li>
  <li><p>second problem is that it didnt return the last element of the array</p>
  </li>
  </ul>
  </blockquote>
  <p><strong>What i have tried:</strong></p>
  <ul>
  <li>i tried to search on google on who to remove duplicates in large arrays but didnt find the result i'm looking for</li>
  <li>and i have tried the function end($array) then array_push function to add the last element to my function, but it didnt work too, and i guess it isnt even the right solution.
  and i didnt receive any clear error to share with you.</li>
  </ul>
  <p>what can the problem be?</p>
  <p>thanks in advance.</p>