Skip to content

Instantly share code, notes, and snippets.

@tyage
Last active April 20, 2016 08:52
Show Gist options
  • Save tyage/0204be0640f14daf601f to your computer and use it in GitHub Desktop.
Save tyage/0204be0640f14daf601f to your computer and use it in GitHub Desktop.
ZipArchive少し変?
#!/bin/sh
php -v # => PHP 5.5.9-1ubuntu4.14
mkdir -p /tmp/test
touch /tmp/test/foo
php zip.php
unzip -l /tmp/archive.zip
# result: foo -> prefix/oo
# Archive: /tmp/archive.zip
# Length Date Time Name
# --------- ---------- ----- ----
# 0 2016-03-27 19:49 prefix/oo
# --------- -------
# 0 1 file
<?php
$zip = new ZipArchive();
$zip->open('/tmp/archive.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$zip->addGlob('/tmp/test/foo', 0, ['add_path'=>'prefix/','remove_path' => '/tmp/test/']);
$zip->close();
@tyage
Copy link
Author

tyage commented Apr 20, 2016

@tyage
Copy link
Author

tyage commented Apr 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment