src/Tar.php
public function contents()
    {
        if ($this->closed || !$this->file) {
            throw new ArchiveIOException('Can not read from a closed archive');
        }

        $result = array();
        while ($read = $this->readbytes(512)) {
            $header = $this->parseHeader($read);
            if (!is_array($header)) {
                continue;
            }

            $this->skipbytes(ceil($header['size'] / 512) * 512);
            $result[] = $this->header2fileinfo($header);
        }

        $this->close();
        return $result;
    }
public function contents()
    {
        if ($this->closed || !$this->file) {
            throw new ArchiveIOException('Can not read from a closed archive');
        }

        $result = array();
        while ($read = $this->readbytes(512)) {
            $header = $this->parseHeader($read);
            if (!is_array($header)) {
                continue;
            }

            $this->skipbytes(ceil($header['size'] / 512) * 512);
            $result[] = $this->header2fileinfo($header);
        }

        $this->close();
        return $result;
    }
public function contents ( ) { if ( $ this -> closed || ! $ this -> file ) { throw new ArchiveIOException ( 'Can not read from a closed archive' ) ; } $ result = array ( ) ; while ( $ read = $ this -> readbytes ( 512 ) ) { $ header = $ this -> parseHeader ( $ read ) ; if ( ! is_array ( $ header ) ) { continue ; } $ this -> skipbytes ( ceil ( $ header [ 'size' ] / 512 ) * 512 ) ; $ result [ ] = $ this -> header2fileinfo ( $ header ) ; } $ this -> close ( ) ; return $ result ; }
Read the contents of a TAR archive

This function lists the files stored in the archive

The archive is closed afer reading the contents, because rewinding is not possible in bzip2 streams.
Reopen the file with open() again if you want to do additional operations

@throws ArchiveIOException
@throws ArchiveCorruptedException
@returns FileInfo[]
Read the contents of a TAR archive