View Full Version : include all the files in a file...?
lankinator
07-24-2007, 05: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, 01:04 AM
<?php
$file = file('text.txt');
foreach ($file as $inc) {
include $inc;
}
?>
$d = opendir('names/');
while($f = readdir($d))
if(strlen($f) - strrpos($f, '.inc.php') === 8)
include $f;
closedir($d);
thetestingsite
07-26-2007, 02: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, 05:47 AM
Yes, it would.
And... yeah... I missed that "file" in this case meant "directory" :p
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.