----- Original Message -----
From: "Loren" <[EMAIL PROTECTED]>

> What I am trying to do is display all of the files in a
> directory in a random order.

You just need to collect a list of all the file names into an array then use
the array elements in a random order.

If you know the name of the directory where the files are ( a real path like
C:\web\youruser\www\files not a URL) you can open the directory with
$d=$dirpath, then read the names of all the files in it into an array
(missing out the "." and ".." you get at the start of a directory listing)

  while ($f = readdir($d)) {
    if ($f == ".") continue;
    if ($f == "..") continue;
    $files[ ] = $f;
  }

Now you can use the PHP function shuffle( ) to put the array into a random
order

  srand ((float)microtime()*1000000);
  shuffle ($numbers);

Now you can use foreach( ) to display the filenames from the randomized
array

  print "Random list of files<br>\n";
  print "<ul>\n";
  foreach ($filenames as $f) {
    print "<li>" . $f . "\n";
  }
  print "</ul\n";

PHP is so easy to use that it's a waste of time trawling for free scripts
when with a copy of the PHP help file (downloadable from php.net) and a few
minutes thought you can almost always do it yourself.  Of course it helps if
you have ever been on any kind of  formal programming course where you learn
to construct your own "algortihms" or solutions to programming problems.

Lots of luck
Bj



____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] 
       Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
    http://wdvl.internet.com/WDVL/Forum/#sub

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to