How to browse a folder without knowing the name in PHP

1

Hello, I need your help, I am making a very complex system (for a change) that in one of the parts of this system, it has to enter a folder, however, this folder will have an indefinite name, the system will have to find what has not been defined in simplification: My system needs to go through a folder, even though I do not know its name, since most of the functions I use, need the folder name as well and for those who find easy this, know that in this system, it used only functions that do not connect with a database. Now I'll give examples about this :

fopen("vaidarerrado/(PASTA NÃO DEFINIDA)/index.php","r");

If you notice, the "fopen" function will go through the folder "vaidarerrado", all right, until when it arrives at something undefined that in the case I marked as: "(PASTA NOT DEFINED) obviously it gives a huge error, because, as a function can go through a folder, that not even the programmer informed ?, (alias the system wants to pass from "(PASTE NOT DEFINED)" because it aims to access the file " index.php "even without knowing which folder it is in) , in another simplification: scrolling through a folder without knowing the name to find a specific file, and the only function I know that takes ANY information from an unspecified folder, and the function:

glob();

EXAMPLE:

count(glob("vaidarerrado/{*}",GLOB_BRACE));

The "glob" code above, even without knowing the name of the folder, can "know its existence" and give the number of things it has in the directory "vaidarerrado", of course, what I want, and go through a folder without knowing its name, to find a file, or if you can, enter the name of the folder. I hope they help me or get to the "Index.php" PASSING BY THE UNDEFINITE PASTE or somehow, getting the name of the folder, good luck to you, I hope some answer; p (kk)

    
asked by anonymous 03.02.2017 / 21:08

1 answer

4

Consider the following file structure:

                                    
03.02.2017 / 21:40