Web Analytics Made Easy -
StatCounter PHP reading outside its parent directory. - CodingForum

Announcement

Collapse
No announcement yet.

PHP reading outside its parent directory.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP reading outside its parent directory.

    I've got:
    /A/index.html
    /A/1/index.listing
    /A/2/index.listing
    /A/3/index.listing
    In index.html, I've got the following PHP code:
    <?php
    $files = glob('./*/*.listing');
    foreach ($files as $file)
    {
    include $file;
    }
    ?>
    As you can see, what PHP code does is include()'s all the index.listing files.

    I then create a clone of the A directory and alter the HTML in the .listing files so can tell the difference between A & B when they render:
    /B/index.html
    /B/1/index.listing
    /B/2/index.listing
    /B/3/index.listing
    The issue I am having is "/B/index.html" is ()including the .listing files from the /A/*/ directory, when it should be including them from the /B/*/ directory.
    I can't understand why this is happening and hoping someone could shed some light on the issue?
    Last edited by Kolusion; Aug 22, 2011, 10:39 AM.

  • #2
    I am not positive about this because I have never included files that way before. Does it have anything to do with the fact that you have two (*). Star means anything matching the criteria, the criteria being one folder forward for the first star. So I would think it would include A, B and C...but like I said, I have never included files that way. It is possible that it is just including the first thing matching the criteria, which would be the 'A' directory index. I am just guessing, but it is a somewhat educated guess.

    Comment


    • #3
      Hey dude,

      Nah it couldn't be that reason because index.html is being execute inside the B directories. Thats what I don't understand... Its including files from a parent directory (A), when it should be including them from child directory /*/. Fully strange huh!

      Comment


      • #4
        I said index, but I meant *.listing. I think it is reading anything two folders forward that has a .listing file name. Does that change anything?

        Comment


        • #5
          No, index.html is being ran inside the A and B directories.
          Last edited by Kolusion; Aug 22, 2011, 11:17 AM.

          Comment


          • #6
            Never mind, there was nothing wrong with the code. It was another problem. The code works.

            Comment

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎