Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-21-2003, 09:42 AM   PM User | #1
mouse
Regular Coder


 
Join Date: Jun 2002
Location: North East England
Posts: 853
Thanks: 0
Thanked 0 Times in 0 Posts
mouse is an unknown quantity at this point
Advanced directory listing?

Hi there,

I can do a basic directory listing. But what I would like is to be able to use the result; for example, display all images in a directory, or create links to all files.

I've tried to do this using str_replace() {as it's one of half a dozen functions I actually know } but I have a problem with three dots messing things up ... So I'm thinking surely there's a better way?

cheers
__________________
[+] Computer/PC issues [+] Silverpaw3D
------------------------------------------------
Never buy a dwarf with learning disabilities...

...it's not big, and it's not clever.
mouse is offline   Reply With Quote
Old 03-21-2003, 09:46 AM   PM User | #2
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
this might be relevant
PHP Code:
<?

//define the path as relative
$path ".";

//open directory for list
$dir_handle = @opendir($path) or die("Unable to open $path");

//print filenames
print "<pre>";
while (
$file readdir($dir_handle)) {
    
//if filename contains .shtml or .phtml 
    
if(ereg("\.[sp]html",$file) {
        
        print 
"<a href=\"$file\">$file</a>\n";
        }
    }

//close directory
closedir($dir_handle);
print 
"</pre>";
  
?>
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 03-21-2003, 10:28 AM   PM User | #3
mouse
Regular Coder


 
Join Date: Jun 2002
Location: North East England
Posts: 853
Thanks: 0
Thanked 0 Times in 0 Posts
mouse is an unknown quantity at this point
That works, well it doesn't with the [sp] bit in place but there's ways around for multiple file types...
__________________
[+] Computer/PC issues [+] Silverpaw3D
------------------------------------------------
Never buy a dwarf with learning disabilities...

...it's not big, and it's not clever.
mouse is offline   Reply With Quote
Old 03-21-2003, 10:50 AM   PM User | #4
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
"insert regex here", innit
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:11 AM.


Advertisement
Log in to turn off these ads.