I am writing a script to extract files from a zip archive to the directory where the script is located.
Here is my code:
$zip = new ZipArchive;
if ($zip->open('latest.zip') === TRUE) {
$zip->extractTo('.');
$zip->close();
unlink('installer.php');
echo 'it works!';
} else {
echo 'failed';
}
This works great, but there is one problem. Zip contains an extra layer. (zip / directory / files), which extracts how this directory / files, not just files.
Is there any way to remove this extra layer?
Thank you for your help!
Joel Draper
source
share