简体   繁体   中英

script printing out first part of array twice

I have a script that i wrote, but it prints the first part of the array twice.

The output that i get is the following:

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

The code is below:

            $currentPath = $path.'images/galleries/phase2/folder1/';

            $dirNew = opendir($currentPath);

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

                            $indexCount = count($dirArray);

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

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

                            }

                    }
                }
                closedir($dirNew);


        }   

Any pointers in the right direction will be welcome.

Thanks in Advance

$indexCount = count($dirArray);

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

Move it after the while {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM