communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "directories" - download "directory list with exec"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

directories - directory list with exec was created/last modified on Fri 16 Apr 2004 9:15 AM

using exec() to produce a directory listing
  
  <?php
  
  exec
('ls -al .', $output, $return );

/*

when you use the -l flag w/ ls, there will be a string of characters on the left for each file, which may look something like -rwxr-xr-x
the first character describes what the item is:
- = regular file
d = directory
b = special block file
c = special character file
l = symbolic link
p = named pipe special file
example: lrwxr-xr-x would be a symbolic link

the next 9 characters are 3 groups of 3 characters each, which tell the read/write/execute permissions for user, group, and other respectively:
r = read
w = write
x = execute
using the above example of lrwxr-xr-x, you would have symbolic link file, where the user can read, write and execute (rwx), and the group and others can read and execute (r-x)

*/

  
echo '<p>Returned: '.$return.'</p>';
  foreach (
$output as $file )
  {
     echo
$file.'<br>';
  }
  
  
?>

learn more about some of the PHP functions used in this snippet: dir, each, echo, exec, file, for, foreach, link, list, next, return

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari