Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a directory index file to re

Status
Not open for further replies.

rfrenke

Programmer
Joined
Jun 21, 2003
Messages
9
Location
US
I have a directory index file to read the contents of a direvtory, and display: An Altered file name, Modified date, and descroption taken from within the file. It builds an HTML table to display the list. My problem is that I can't figure out how to do a descending sort by file name when it displays the list. HELP!!!!!!!!!!!

Code:
<html>
<head>
</head>
<body>
<center>
<?php 
echo &quot;<table cellspacing=0 cellpadding=8 width=70%>&quot;;
echo &quot;<tr>
<td bgcolor=000099></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>FILE</center></b></font></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>MODIFIED</center></b></font></td>
<td bgcolor=000099><font color=eeeeee size=-1em><b><center>DESCRIPTION</center></b></font></td></tr>&quot;;
if ($handle = opendir('.')) 
	{
	
	$i=&quot;1&quot;;	
		
    	while (false !== ($file = readdir($handle))) 
    		{ 
    		
     	
    		
    	    	if (preg_match(&quot;/FileA\d+\.php/i&quot;,$file)) 
    	    	{ 
    	    	
			
			
			        $phpStripped = str_replace(&quot;.php&quot;, &quot;&quot;, $file);
    	    		$earSpace = str_replace(&quot;FileA&quot;, &quot;File #&quot;, $phpStripped);
    	    		$earSpace = strtoupper($earSpace);

    	    		
    	    	    echo &quot;<tr><td>$i</td><td><font size=2em><b><a href=$file>$earSpace</a>  </b></font></td>&quot;;
    	    	    
    	    	    $t=date(&quot;d.M.Y H:i&quot;, filemtime($file)); 
    	    	    
    	    	    echo &quot; <td><font size=2em><b>$t</font></b></td>&quot; ;
    	    	    
    	    	    $fp = fopen($file, &quot;r&quot;);
    	    	    $contents = fread($fp, filesize($file));
    	    	    $descript1 = explode(&quot;\n&quot;, $contents);
    	    	    $descript2 = str_replace(&quot;<td>&quot;, &quot;&quot;, $descript1[28]);
    	    	    $description = str_replace(&quot;</td>&quot;, &quot;&quot;, $descript2);

    	    	    echo &quot; <td><font size=2em><b>$description</b></font></td></tr> &quot;;
    	      	    
		            ++$i;	     
    	    		
    	    	} 
    	    	
		
    	    	 
    		}
    	closedir($handle); 
	}

echo &quot;</table>&quot;;
?>
</center>
</body>
</html>
 
Had to step away from this one temporarily... but it worked like a charm!!!!!
 
what does that mean !==

To err is human, to completely mess up takes a computer. [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top