NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Simple directory listing function

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 04-18-2006, 09:40 PM THREAD STARTER               #1 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics

Simple directory listing function


A simple function to list a given directory's files. Got bored

PHP Code:
<?php

function list_dir($dir$ignore = array())
{
  
$handle opendir($dir);

  if(
$handle)
  {
    while(
false !== ($file readdir($handle)))
????: NamePros.com http://www.namepros.com/code/188858-simple-directory-listing-function.html
    {
      if(
$file != '.' && $file != '..' && !in_array($file$ignore))
      {
        
$files[] = $file;
      }
    }
    
sort($files);
    
$list '';

    foreach(
$files as $file)
    {
      
$list .= $file.'<br>';
    }
????: NamePros.com http://www.namepros.com/showthread.php?t=188858
  }
  
closedir($handle);
  
  return 
rtrim($list'<br>');
}

/*
Takes two arguments $dir & $ignore
$dir = the directory you want to list
$ignore = an array of specific files you don't want listed

Example usage:
*/

echo list_dir("some/directory/", array("includes""someotherfile.php"));

/*
Outputs something like:

about.php
contact.php
index.php
style.css

... you get the idea ;)
*/

?>
Eric is offline  
Old 04-21-2006, 12:56 AM   #2 (permalink)
NamePros Member
Join Date: Apr 2006
Location: NY
Posts: 32
cashboy is an unknown quantity at this point
 



can you list files from the remote server using this script? if not, is there any way to?
__________________
- Steve :$: :)
cashboy is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:42 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger