Re: Having an issue with a Directory Listing in the php Scripting

From: Date: Fri, 09 Aug 2002 16:32:20 +0000
Subject: Re: Having an issue with a Directory Listing in the php Scripting
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-111840@lists.php.net to get a copy of this message
On Fri, Aug 09, 2002 at 08:58:41AM -0500, §§ Duncan MacLeod §§ wrote: > I am only being able to list the first > file in each of the directories. Not the entire directory. ... snip ... > Although, the only files I really need out of the > directory are going to be '.JPG', '.jpg', '.GIF', > '.gif', '.JPEG', '.jpeg'. While this doesn't do exactly what your script does, it will point you in the right direction... <?php $DirHandle=opendir('.'); while ($FileName = readdir($DirHandle)) { switch ( substr($FileName, -4) ) { case '.jpg': case '.JPG': case 'jpeg': case 'JPEG': case '.gif': case '.GIF': $FileList[] = $FileName; break; } } # Sort the list alphabetically: asort($FileList); echo '<ul>'; while (list(,$Name) = each($FileList) ) { echo "<li><a href=\"$Name\">$Name</a></li>\n"; } echo '</ul>'; ?> -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

« previous php.general (#111840) next »