palli 0 Report post Posted April 4, 2005 Need help to include this, i am trying to include this folderhttp://forums.xisto.com/no_longer_exists/ to this http://forums.xisto.com/no_longer_exists/the folder include many fileshttp://forums.xisto.com/no_longer_exists/i want to include all the files in a certain directory. do i use reddir for this, how can i do this echo "<PRE>";$handle = opendir(".");while($file = readdir($handle)) {if(is_dir($file)) echo "$file/\n";else echo "$file\n";}closedir($handle);echo "</PRE>"; do i have to loop to include each file.?? Share this post Link to post Share on other sites
round 0 Report post Posted April 5, 2005 I don't think you can include a whole folder. I think you can work it out so that your directory list is included like a config file that gets updated when your directory is changed(when files are deleted or created. I would love to help but don't have time right now. If you look on php.net you might be able to something there that might help you out.round Share this post Link to post Share on other sites
Spectre 0 Report post Posted April 5, 2005 I would recommend going with round's suggestion. A folder may contain other files that you do not wish to include, such as, for example, .htaccess. Having a configuration file which explicitly specifies which files to include might take a little longer to put together, but would be a much better idea overall. Share this post Link to post Share on other sites
no9t9 0 Report post Posted April 5, 2005 $dh = opendir("shoutbox_v1.2");while ($temp=readdir($dh)) { if ($temp!="." && $temp!="..") { include($temp); }}this will include all files in your "shoutbox_v1.2" directory. IF you want to skip certain files, just add them in the IF condition. Right now, the if condition skips "." and ".." because those are not files.You also might want to add $temp!=".htaccess" as well...you can also exclude (or include) files using string functions like eregi and strstr. For example, if you only want to include .php files you only need 1 condition in the if statement. example: if (eregi("\.php",$temp)) will only include php files from the directory "shoutbox_v1.2" another example: if (eregi("\.php",$temp) || eregi("\.html",$temp)) will include all .php files and .html filesanyway, modify the if condition to do what you want it to. Share this post Link to post Share on other sites
no9t9 0 Report post Posted April 5, 2005 no edit button...you might have to add the directory in front of the $temp variable for your include statement.include ("shoutbox_v1.2/".$temp);this depends on where you call this script. IF it is within the shoutbox_v1.2 directory, you don't need it. If it is in the root (which your original post suggests), you will need it. Share this post Link to post Share on other sites