Log in

View Full Version : include all the files in a file...?



lankinator
07-24-2007, 04:05 PM
how can / do you make a php script that will include all the files in a file like (names/) without you having to specify include "names/1.php" etc?

djr33
07-26-2007, 12:04 AM
<?php
$file = file('text.txt');
foreach ($file as $inc) {
include $inc;
}
?>

Twey
07-26-2007, 01:45 AM
$d = opendir('names/');
while($f = readdir($d))
if(strlen($f) - strrpos($f, '.inc.php') === 8)
include $f;
closedir($d);

thetestingsite
07-26-2007, 01:58 AM
$d = opendir('names/');
while($f = readdir($dir))
if(strlen($f) - strrpos($f, '.inc.php') === 8)
include $f;
closedir($d);

Wouldn't it be this instead?



$d = opendir('names/');
while($f = readdir($d))
if(strlen($f) - strrpos($f, '.inc.php') === 8)
include $f;
closedir($d);


Beings that $dir is not defined.

djr33
07-26-2007, 04:47 AM
Yes, it would.
And... yeah... I missed that "file" in this case meant "directory" :p

Twey
07-26-2007, 07:41 AM
Aye, sorry -- edited.