note 117821 added to ref.zip
| From: | vk.com/vknkk | Date: | Fri, 14 Aug 2015 07:01:20 +0000 |
| Subject: | note 117821 added to ref.zip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203343@lists.php.net to get a copy of this message | ||
<?php
// Extracting all *.zip files (including subfolders) into current directory (developed & tested
at Win7)
$files = glob('*.zip');
if ($files)
foreach ($files as $fl) {
$zip = zip_open($fl);
if (is_resource($zip)) {
$dir = substr($fl, 0, -4); // Directory by *.zip file name (Extract into "*/")
if (!is_dir($dir))
mkdir($dir);
while (is_resource($entry = zip_read($zip))) {
$is_file = true;
$name = zip_entry_name($entry);
$name_parts = explode('/', $name);
if (count($name_parts) > 1) { // Processing subfolders
$path = array_pop($name_parts);
$is_file = !empty($path);
$path = $dir;
foreach ($name_parts as $part) {
$path .= '/'.$part;
if (!is_dir($path))
mkdir($path);
}
}
if ($is_file)
file_put_contents($dir.'/'.$name, zip_entry_read($entry,
zip_entry_filesize($entry)));
}
zip_close($zip);
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 37.229.178.61
----
Manual Page -- http://php.net/manual/en/ref.zip.php
Edit -- https://master.php.net/note/edit/117821
Del: integrated -- https://master.php.net/note/delete/117821/integrated
Del: useless -- https://master.php.net/note/delete/117821/useless
Del: bad code -- https://master.php.net/note/delete/117821/bad+code
Del: spam -- https://master.php.net/note/delete/117821/spam
Del: non-english -- https://master.php.net/note/delete/117821/non-english
Del: in docs -- https://master.php.net/note/delete/117821/in+docs
Del: other reasons-- https://master.php.net/note/delete/117821
Reject -- https://master.php.net/note/reject/117821
Search -- https://master.php.net/manage/user-notes.php