Order of directory contents
Posted: Tue Dec 16, 2008 2:14 pm
Does anyone know why the results are out of numeric order?
returns
Code: Select all
$images="images/work/{$id}/";
$dir=opendir($images);
while($name=readdir($dir)){
if (preg_match("/([0-9]+\.jpg)$/",$name)){
$str=substr($name,0,-4);
if($switch==FALSE){
$active="class=\"active\"";
$switch=TRUE;
} else {
$active="";
}
$tags['gallery'].="<li {$active}><a href=\"{$images}{$str}.jpg\"><img src=\"{$images}{$str}t.jpg\" width=\"61\" height=\"50\" alt=\"{$value['project_name']}\" /></a></li>\n";
}
}Code: Select all
<li class="active"><a href="images/work/118/9.jpg"><img src="images/work/118/9t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/1.jpg"><img src="images/work/118/1t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/2.jpg"><img src="images/work/118/2t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/5.jpg"><img src="images/work/118/5t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/6.jpg"><img src="images/work/118/6t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/3.jpg"><img src="images/work/118/3t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/7.jpg"><img src="images/work/118/7t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/8.jpg"><img src="images/work/118/8t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>
<li ><a href="images/work/118/4.jpg"><img src="images/work/118/4t.jpg" width="61" height="50" alt="Los Morros Master Plan" /></a></li>