Forum Moderators: coopster
I'm looking for help on requiring all files found in a directory. I came across this script:
<?php
foreach(glob('*'.'.html') as $file) {
echo $file;
}
?>
I had replaced echo $file with require_once $file; but it had thrown an error? I guess require/include does not work with foreach?
Anyone have any insight? Thanks-
the script worked! Just made one modification to it:
<?php
$dir = '905';
$fp = @opendir($dir);
while ($file = @readdir($fp)) {
if (preg_match('/.*?\.html/i', $file)) {
require_once($dir.'/'.$file); [b]// had to concatenate a '/' between the $dir and the $file variables [/b]
}
}
@closedir($fp);
?>