'PHP - How to read zip file content?

I want to read a zip file from web which consists of a couple .srt files.

With the code I have, I successfully downloaded the zip archive and read each of its file names and content.

In the other part of the code, The program is asking me to specify direct path to srt file. Of course, it's not just the name, but a file that should be opened. How could I do that?

Thanks for your time.

<?php 
    ini_set ("display_errors", "1");
    error_reporting(E_ALL);

    $file = 'https://titlovi.com/download/?type=1&mediaid=345941';
    if (!copy($file, $_SERVER["DOCUMENT_ROOT"]."/movies/subtitles/".basename($file, ".zip")."")) {
        echo "failed to copy $file...\n";
    }
    $za = new ZipArchive(); 
    $za->open($_SERVER["DOCUMENT_ROOT"]."/movies/subtitles/".basename($file, ".zip").""); 
    for( $i = 0; $i < $za->numFiles; $i++ ){ 
        $stat = $za->statIndex( $i ); 
        echo $za->getFromName(basename( $stat['name'] ));
    }
    $za->close();
?>
                            srclang: 'en',
                            label: 'subtitle',
                            src: 'hereshouldbe.srt',
                            default: true,


Solution 1:[1]

You can extract zip file into a folder, and open each file in that folder

$za->extractTo($path);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Khanh Nguyen