Jump to content

Archived

This topic is now archived and is closed to further replies.

acroporas

How to control Glob(

Recommended Posts

I'm trying to figure out how to control which folder the glob( function looks at?  (I've noticed that it does not allways search the same folder that the php file calling the function is in.) 

Is there a website that goes into more detail about the funtions than what is found in the php manual.


Also, is there a better way to get the list of files in a folder that is more easily controlable?

Thanks

Will

Share this post


Link to post
Share on other sites
I've never had a problem using the glob() function. What problems are you having?

Do you have code samples you can post?

Ken

Share this post


Link to post
Share on other sites
It is difficult to post code snippets as  the problem is not in just one line but I can explain one example of what I call 'hard to control' 

I have the following file system.

home directory
          header.php

          child directory 1
                  page.php

         child directory 2
                 java.js

page.php has in it the line:    include ( ../header.php )
and
header.php has in it the line:  glob('*.*')

Case 1:  header.php has the line "../child-directory2/java.js"
Glob returns files in home directory.

Case 2:  header.php has the line "http://www.home directory.com/child directory 2/java.js"
Glob returns files in child directory 1

Edit...I've change my code significantly so this is from memory so it may not be exactly as it was.  But the theme is accurate.  Changing how I refrenced the .js file from a relative link to a absolute link changed wich directory glob would search.

Share this post


Link to post
Share on other sites
If you can create pieces of code that show the problem, it would be much better.

Ken

Share this post


Link to post
Share on other sites

×

Important Information

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.