NameSilo

Simple directory listing function

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch
A simple function to list a given directory's files. Got bored :)

PHP:
<?php

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

  if($handle)
  {
    while(false !== ($file = readdir($handle)))
    {
      if($file != '.' && $file != '..' && !in_array($file, $ignore))
      {
        $files[] = $file;
      }
    }
    sort($files);
    $list = '';

    foreach($files as $file)
    {
      $list .= $file.'<br>';
    }
  }
  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 ;)
*/

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
can you list files from the remote server using this script? if not, is there any way to?
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back