title: Need to hide the class according to the directory opened
body: <p>I'm new here and a beginner. I will try to elaborate my problem and so please try to understand and respond and thanks for your help in advance.
  QUESTION:I had just taken the details of a directory named images and for which the output exists, but whereas I'm in need to make this directories to show one by one.
  i.e,my response before adding jquery was shown below:</p>
  
  <pre><code>hari/
              1/
                  Kick Buttowski5.png
                  hari1.1/
                      Kick Buttowski0.png
                      kick_buttowski.png
              2/
                  Kick Buttowski0.png
                  kick_buttowski.png
              3/
                  Kick Buttowski0.png
              Kick Buttowski5.png
  
          hari1/
  
              2/
                  Kick Buttowski0.png
                  kick_buttowski.png
              kick_buttowski.png
  
          hari2/
  
              Kick Buttowski5.png
  
  and the response after jquery was:
  
  hari/
  hari1/
  hari2/
  </code></pre>
  
  <p>So I just want the output as specified below if I click hari directory alone:</p>
  
  <pre><code>  hari/
          1/
              Kick Buttowski5.png
              hari1.1/
          2/
          3/
      hari1/
      hari2/
  </code></pre>
  
  <p>And output as follows if if I click hari/hari1.1/ directory alone</p>
  
  <p>1/
          Kick Buttowski5.png
          hari1.1/
              Kick Buttowski0.png
              kick_buttowski.png
      2/
      3/
  hari1/
  hari2/</p>
  
  <p>Likewise for each and every individual folders one by one. Sorry for this long confusing description, but am not sure how to explain short. I hope this could be solved as soon as possible.</p>
  
  <p>Here is my code that I used :</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;title&gt;Reading a Tree of Files and Folders&lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"&gt;
          &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script type="text/javascript"&gt;
  
              $(document).ready(function () {
                  a = $('#counn').val();
                  var checkBoxClasses = [];
                  for (i = 1; i &lt;= a; i++) {
                      checkBoxClasses += i;
                      $('.hide' + i).toggle();
                  }
                  var arr =checkBoxClasses.split("");                
                  $.each(arr, function (index, value) {
                      x = value;
                      //alert(x);
                      $('.show' + x).click(function () {
                          $('.hide' + $(this).attr('id')).toggle();
                      });
  
                  });
  
              });
  
          &lt;/script&gt;
  
          &lt;?php
          $folderPath = "images";
  
          function readFolder($path) {
  
              // Open the folder
              if (!( $dir = opendir($path) )) {
                  die("Can't open $path");
              }
              $filenames = array();
  
              // Read the contents of the folder, ignoring '.' and '..', and
              // appending '/' to any subfolder names. Add all the files and
              // subfolders to the $filenames array.
  
              while ($filename = readdir($dir)) {
                  if ($filename != '.' &amp;&amp; $filename != '..') {
                      if (is_dir("$path/$filename")) {
                          $filename .= '/';
                      }
                      $filenames[] = $filename;
                  }
              }
  
              closedir($dir);
  
              // Sort the filenames in alphabetical order
              sort($filenames);
              // Display the filenames, and process any subfolders
              ?&gt;
              &lt;input type="hidden" value="&lt;?php echo count($filenames); ?&gt; " id="counn"&gt;
              &lt;?php
              echo "&lt;ul&gt;";
              $i = 1;
              foreach ($filenames as $filename) {
                  echo '&lt;li class="show' . $i . '" id=' . $i . ' &gt;' . $filename;
                  echo '&lt;div class="hide' . $i . '" &gt;';
                  if (substr($filename, -1) == '/') {
                      readFolder("$path/" . substr($filename, 0, -1));
                  }
                  echo '&lt;/div&gt;';
                  echo "&lt;/li&gt;";
  
                  $i++;
              }
  
              echo "&lt;/ul&gt;";
          }
  
          echo "&lt;h2&gt;Contents of folder =&gt; $folderPath:&lt;/h2&gt;";
          readFolder($folderPath);
          ?&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>