Q:

Getting direct path of directory which contain pages using PHP

Root

First_Folder

First_Folder_Pages
First_Folder_JS(js script here for ajax)
First_Folder_DB(php script that is linked from ajax request)

Second_Folder

Second_Folder_Pages
Second_Folder_JS(js script here for ajax)
Second_Folder_DB(php script that is linked from ajax request)

How can I get the direct path on the folder with names containing Pages using jQuery or PHP
Expected Output is like: ../../First_Folder/First_Folder_Pages  or ../../Second_Folder/Second_Folder_Pages 

A:

This function w'd be enough for file list. Just make an ajax call to it, json_encode to output before send back to javascript
function scan($dir)
    {
        $output = array();
        $handle = opendir($dir);

        if ($handle != false) {
            while ($file = readdir($handle)) {
                if ($file == '.' || $file == '..')
                    continue;

                $path = $dir . '/' . $file;

                if (is_dir($path))
                    $output += scan($path);
                else
                    $output[] = $path;
            }
        }

        return $output;
    }

İf you want to add folders to array too, just change the if statement like;
if (is_dir($path))
    $output += scan($path);

$output[] = $path;

Also you can use RecursiveDirectoryIterator class too: stackoverflow
UPDATE
Just erase the "else" keyword if you want to add folders too in output.
If you call function like;
scan('/root/');

The output will give you results like; 
'/root/First_Folder/First_Folder_file1',
'/root/Second_Folder/Second_Folder_file1',
'/root/Second_Folder/Second_Folder_file2'

But if u erase "else" keyword, you will get results like; 
'/root/First_Folder',
'/root/First_Folder/First_Folder_file1',
'/root/Second_Folder',
'/root/Second_Folder/Second_Folder_file1',
'/root/Second_Folder/Second_Folder_file2' 

