[Sussex] PHP Question: How to include all files in a directory

Chris Jones cmsj at tenshu.net
Wed Feb 16 01:04:14 UTC 2005


Hi

On Mon, February 14, 2005 10:29, Gareth Ablett said:
> if ( $myfiles = scandir($dir) )

afair scandir is new in php5, which most people aren't running yet.

This should do roughly the same on PHP4:

$dir=".";
$dh = opendir($dir);
while($filename = readdir($dh)) {
  if (substr($filename, -4, 4) != ".php")
    continue;
  printf ("%s\n", $filename);
}

Cheers,
-- 
Chris Jones
  cmsj at tenshu.net
   www.tenshu.net





More information about the Sussex mailing list