Jump to content
xisto Community
Sign in to follow this  
palli

Include Help

Recommended Posts

Need help to include this, i am trying to include this folder
http://forums.xisto.com/no_longer_exists/ to this http://forums.xisto.com/no_longer_exists/

the folder include many files
http://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

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

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

$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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.