I am trying to get the 32424df344.json file within folder of zip file
File Structure:
- politi.zip
-> tweet folder
-> 32424df344.json file
<?php
$z = new ZipArchive();
if ($z->open(dirname(__FILE__) . '/politi.zip')) {
$json = $z->getFromName("32424df344.json");
if ($json) {
//decode json array
$json_array = json_decode($json);
var_dump($json_array);
}
}
?>
My Answer:
This code should work to get the 32424df344.json file within the tweet folder of the zip file without extracting it. Just make sure that the path to the zip file is correct and that the file structure within the zip file matches what you have described.
Rate this post
3 of 5 based on 1214 votesComments