title: Overwrite foreach output if duplicate value exists
body: <p>I've a folder on server, m fetching those files but getting some difficulties. my code is</p>
  
  <pre><code>$dir = 'F:\\wamp\www\files';
  if (is_dir($dir)) {
  if(($file = scandir($dir))!==false) {    
  
      foreach ($file as $key =&gt; $value) {                  
          $name = substr($value,0,-7);   
  </code></pre>
  
  <p>the scandir()  function retuns array of files which returns list of names, i.e.</p>
  
  <pre><code>manoj254.txt
  manoj234.txt
  pooza145.txt
  pooza452.txt
  ramesh418.txt
  ramesh231.txt  
  </code></pre>
  
  <p>and i've remove the extension by using substr() function after this the output is $name  </p>
  
  <pre><code>manoj
  manoj
  pooza
  pooza
  ramesh
  ramesh
  </code></pre>
  
  <p>But i need the output $name, without duplicate.i.e  </p>
  
  <pre><code>manoj
  pooza
  ramesh
  </code></pre>
  
  <p>which means remove duplicates... can any body help me plz !!</p>