Thumbnailid

preg_find salvestab sorteeritud listi JPG failidest thumbs/*/small kataloogides:

<?php
include ('preg_find.php');
$files = preg_find ('/.jpg$/D', '../thumbs',PREG_FIND_RECURSIVE|PREG_FIND_SORTKEYS);
$fh = fopen("list.txt", "w") or die();
foreach ($files as $file)
   if (strpos ($file, "/small/") > 0) {
    fwrite($fh, str_replace("../thumbs/","",$file) . "\n");
   }
fclose($fh);
?>

Edasi võtab RandomLine salvestatud failist suvalisi ridu:

function RandomLine($filename) {
   if (!isset($lines)) $lines = file($filename);
  return $lines[array_rand($lines)];
}
$line = RandomLine("list.txt");

Proovi