я сделал некоторые исследования и вот что я придумал это работает очень хорошо, и я добавил комментарии, чтобы сделать его легко понять
<?php
$zip = new ZipArchive;
$dir = __DIR__ . '/test'; // directory name
$zipFileName = __DIR__ . '/ahmad.zip'; // zip name
$fileName ='ahmad.php'; //file name
// unzip the archive to directory
$res = $zip->open($zipFileName);
if ($res === TRUE) {
$zip->extractTo($dir);
$zip->close();
} else {
echo 'failed, code:' . $res;
}
// search for the file in the directory
$array = (scandir($dir));
if (in_array($fileName, $array)) {
echo "File exists";
}
else {
echo "file doesn't exist";
}
// Delete the directory after the search is done
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it,
RecursiveIteratorIterator::CHILD_FIRST);
foreach($files as $file) {
if ($file->isDir()){
rmdir($file->getRealPath());
} else {
unlink($file->getRealPath());
}
}
rmdir($dir);
?>
или вы можете пойти на
<?php
$z = new ZipArchive();
if($z->open('test.zip') === TRUE)
{
if ($z->locateName('test.php') !== false)
{
echo "file exists";
}else {
echo "file doesn't exist";
}
}
else {
echo 'failed to open zip archive';
}
?>
который намного проще пользователь отправил в качестве ответа, затем удалил его o я добавил его слишком
http://php.net/manual/en/ziparchive.statname.php – ceejayoz