Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * @param \ZipArchive $archive
  4. *
  5. * @return array
  6. */
  7. function getFiles(ZipArchive $archive)
  8. {
  9. $output = [];
  10.  
  11. for ($i = 0; $i < $archive->numFiles; ++$i) {
  12. $explode = explode('/', $archive->getNameIndex($i));
  13. $pop = array_pop($explode);
  14. $stat = $archive->statIndex($i);
  15. $stat['name'] = $pop;
  16.  
  17. if (empty($explode)) {
  18. $output['/'][] = $stat;
  19. } elseif ('' != $pop) {
  20. $output[implode('/', $explode)][] = $stat;
  21. }
  22. }
  23.  
  24. return $output;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement