1

Can someone help me to unzip the newest zip file in a directory.

I can unzip a file using the specific file name, but unfortunately, the file name changes daily. So unzipping the latest file is my best option.

Or

Can someone show me how to unzip a zip file using the *.zip wildcard and then delete the zip file.

I have tried using the wildcard to unzip, but the wildcard doesn't work for the initial unzip.

$zip = new ZipArchive;
$res = $zip->open('/home/*.zip');
if ($res === TRUE) {
  $zip->extractTo('/home/');
  $zip->close();
  echo 'woot!';
} else {
  echo 'doh!';
}
PaulW32
  • 63
  • 4
  • Is your real question, “how do I find the newest file of a given extension in a directory”? If so, see https://stackoverflow.com/a/2667105/231316 – Chris Haas Jan 02 '23 at 14:30

0 Answers0