title: Extracting specific file to destination from zip in PHP
body: <p>I have zip which contains like this </p>
  
  <p>Search and find almost similar but not fully qualified for me 
  <a href="https://stackoverflow.com/questions/2706901/extracting-specific-files-from-zip-in-php">Link 1</a>
  &amp; <a href="https://stackoverflow.com/questions/27557969/ziparchive-extraction-single-file">Link 2</a></p>
  
  <p><strong>activity_plugin</strong></p>
  
  <ul>
  <li>src 
  
  <ul>
  <li>Controller 
  
  <ul>
  <li>SomeController.php </li>
  <li>SomeOtherController.php</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>I want to extract this two files not the whole directory to my destination directory app/Http/Controller in Laravel framework.</p>
  
  <p>I am able to unzip the whole with root directory src > controller > files but I only want to unzip files to destination.How I can achieve that?</p>
  
  <p>So far tried code - </p>
  
  <pre><code>$destinationPath = 'resources/plugins/';
  $file_path = $destinationPath.$fileName;
  $zip = new \ZipArchive();
  $zip-&gt;open($file_path);
  $zip_bool = zip_open($file_path);
  if ($zip_bool) {
      while ($zip_entry = zip_read($zip_bool)) {
           if (substr(strrchr(zip_entry_name($zip_entry), '/'), 1)) {
              $plugin = substr(strrchr(zip_entry_name($zip_entry), '/'), 1);
  
              if (basename(dirname(zip_entry_name($zip_entry))) == "Controllers") {
                  $dir = app_path()."/Http/Controllers";
                  $path = zip_entry_name($zip_entry);
                  $zip-&gt;extractTo($dir, $x);
              }
  
              $dir = explode('/', zip_entry_name($zip_entry));
              array_pop($dir);
              $newpath = implode('/', $dir);
          }
      }                                  
  }
  </code></pre>