Larandar
Larandar

Reputation: 132

Use tar.gz file like a folder?

Does PHP have an extension that permits to use a tar.gz like a folder?

I have some file that uses a similar structure and I don't need to extract all to read information about it, so can I make file_get_contents("my/path/to/tar/something.tar.gz/out.json");?

Upvotes: 7

Views: 229

Answers (1)

kba
kba

Reputation: 19466

Use PHP's Phar extension. For an introduction, see PHP: Using Phar Archives: Introduction.

file_get_contents("phar://my/path/to/tar/something.tar.gz/out.json");

If you don't already have Phar, you can install the PHP_Archive package or use the PECL extension.

Upvotes: 3

Related Questions