title: Button not working
body: <p>I want to create a button which will copy the directory address.
  But by using the following code I am only getting the value of first item in <code>final_array</code>.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Directory Listing&lt;/title&gt;
      &lt;script&gt;
          function copyToClipboard(text) {
              window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
          }
      &lt;/script&gt; 
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;?php
      $root = 'MyPictures/';
  
      $iter = new RecursiveIteratorIterator(
      new RecursiveDirectoryIterator($root,         RecursiveDirectoryIterator::SKIP_DOTS),
          RecursiveIteratorIterator::SELF_FIRST,
          RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
          );
  
      $paths = array($root);
      foreach ($iter as $path =&gt; $dir) {
          if ($dir-&gt;isDir()) {
              $paths[] = $path;
          }
      }
      $count = sizeof($paths);
  
      $new_arr;
      $final_arr;
  
      for($i=2;$i&lt;$count;$i++) {
          $new_arr[$i] =  str_replace("MyPictures","", $paths[$i]);
          $final_arr[$i] = str_replace("\\","/", $new_arr[$i]);
  
          echo '&lt;br&gt;';
          echo '&lt;button id="demo" onclick="copyToClipboard(document.getElementById(' . "'demo'" . ').innerHTML)"&gt;' . $final_arr[$i] . '&lt;/button&gt;';    
          echo  '&lt;br&gt;';
      } 
      ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Like by clicking any button I am getting first element in the copy dialog box.</p>