title: php - get sub-sub-folder and specific files name and path
body: <p>I would to retrieve from a path all sub (and sub-sub) directories and all files (only with .php and .css extensions) in (last sub) it.</p>
  
  <p>The structre is the following:</p>
  
  <pre><code>my_path/sub-folder1/            // I want to get the sub folder name (and check if allowed)
       sub-sub-folder1/file1.php  // I want to get the file name and path
       sub-sub-folder1/file1.css  // I want to get the file name and path
       sub-sub-folder2/file2.php  // ....
       sub-sub-folder2/file2.css
       sub-sub-folder3/file3.php
       sub-sub-folder3/file3.css
  my_path/sub-folder2/
       sub-sub-folder1/file1.php
       sub-sub-folder1/file1.css
       sub-sub-folder2/file2.php
       sub-sub-folder2/file2.css
       sub-sub-folder3/file3.php
       sub-sub-folder3/file3.css
  </code></pre>
  
  <p>I know the <code>my_path</code>directory name. About sub-folder, I only want to retrieve sub-folder which have the name (<code>sub-folder1</code>, <code>sub-folder2</code> for example). And I would like to retrieve all sub-sub-folders and inside them and get the name and path of the .css and .php files inside it. I'm not sure if I'm clear with my explanations.</p>
  
  <p>My aim is to store all this information in an array like this:</p>
  
  <pre><code>$data['sub-folder-1']= array(
     'sub-sub-folder1' =&gt; array(
         'name' =&gt; 'file1',
         'php'  =&gt; 'file1.php',      
         'css'  =&gt; 'file1.css',
     ),
     'sub-sub-folder2' =&gt; array(
         'name' =&gt; 'file2',
         'php'  =&gt; 'file2.php',      
         'css' =&gt; 'file2.css',
     ),
     ...
  );  
  $data['sub-folder-2']= array(
     'sub-sub-folder1' =&gt; array(
         'name' =&gt; 'file1',
         'php'  =&gt; 'file1.php',      
         'css'  =&gt; 'file1.css',
     ),
     'sub-sub-folder2' =&gt; array(
         'name' =&gt; 'file2',
         'php'  =&gt; 'file2.php',      
         'css'  =&gt; 'file2.css',
     ),
     ...
  );
  </code></pre>
  
  <p>I have started with this code but I have some difficulties to make it works (and it's not finished), I don't use this kind of functionnality a lot...</p>
  
  <pre><code>$dirname = 'my_path';
  $findphp = '*.php';
  $findcss = '*.css';
  $types   = array('sub-folder1','sub-folder2');
  
  $sub_dirs = glob($dirname.'/*', GLOB_ONLYDIR|GLOB_NOSORT);
  
  if(count($sub_dirs)) {
      foreach($sub_dirs as $sub_dir) {
          $sub_dir_name = basename($sub_dir);
          if (in_array($sub_dir_name,$types)) {
              $sub_sub_dirs = glob($sub_dir.'/*', GLOB_ONLYDIR|GLOB_NOSORT);
              if(count($sub_sub_dirs)) {
                  foreach($sub_sub_dirs as $sub_sub_dir) {
                      $php = glob($sub_sub_dir.'/'.$findphp);
                      $css = glob($sub_sub_dir.'/'.$findcss);
                      $sub_sub_dir_name =  basename($sub_sub_dir);
                      $data[$sub_dir_name][$sub_sub_dir_name]['type'] = $sub_dir_name;
                      $data[$sub_dir_name][$sub_sub_dir_name]['name'] = basename($php[0], '.php');
                      $data[$sub_dir_name][$sub_sub_dir_name]['html'] = $php[0];
                      $data[$sub_dir_name][$sub_sub_dir_name]['css']  = $css[0];
                  }
              }
          }
      }
  } else {
      echo "Nothing was found.";
  }
  print_r($data);
  </code></pre>