We have some html code like:
<body>Some text</body>
And a variable $contents.
Its first time I work with zip in php, have a couple of questions.
How do I:
-
create a folder named
HTMLand place it inside$contents(no real creation on ftp, just in variable) -
create an
index.htmland place it insideHTMLfolder, which is inside$contentsSo the
$contentsbefore zip should contain:/HTML/index.html (with <body>Some text</body> code inside) -
create a zip archive with all the content inside
$contentsvariable.
If I understand you correctly:
I’m not using a library to zip it, just the command line, but you could use a library if you wished (but I am checking to see if
zipexecuted correctly).If you really want to do everything truly in memory, you can do this:
http://www.php.net/manual/en/ziparchive.addfromstring.php