script printing out first part of array twice
<p>I have a script that i wrote, but it prints the first part of the array twice. </p>

<p>The output that i get is the following: </p>

<p>2009_06_09_02_07_57_Phase2_04.jpg
2009_06_09_02_07_33_Phase2_03.jpg
2009_06_09_02_07_57_Phase2_04.jpg</p>

<p>The code is below:</p>

<pre><code>   $currentPath = $path.'images/galleries/phase2/folder1/';

   $dirNew = opendir($currentPath);

          while ($file = readdir($dirNew)) {
              if($file != "." &amp;&amp; $file != ".." &amp;&amp; $file != "Thumbs.db" &amp;&amp; $file != "index.html" &amp;&amp; $file != "index.php") { 
       $dirArray[] = $file;

       $indexCount = count($dirArray);

       sort($dirArray);
       for($i=0; $i &lt; $indexCount; $i++) {
        print $dirArray[$i].'&lt;br /&gt;';

      /*echo '&lt;br /&gt;&lt;a href="'.$currentPath.$dirArray[$i].'" title="image 1" class="thickbox" rel="phase 2"&gt;
&lt;img src="'.$currentPath.$dirArray[$i].'" width="75" height="75" border="0"&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Click image &lt;br /&gt;for slideshow';*/

       }

     }
          }
          closedir($dirNew);


  }
</code></pre>

<p>Any pointers in the right direction will be welcome. </p>

<p>Thanks in Advance</p>
