note 100963 added to rar.examples
| From: | Nitrogen at osu1 dot php dot net | Date: | Wed, 17 Nov 2010 16:43:22 +0000 |
| Subject: | note 100963 added to rar.examples | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174125@lists.php.net to get a copy of this message | ||
A veeery simple function to RAR files, I'm not proud of it.
Since there's no way to create RAR files in PHP (due to licensing, patents or whatever),
I'm taking some advantage from the command-line RARing tool that comes with WinRAR (in the
WinRAR program files named "rar.exe").
<?php
function RARFiles($Output='output.rar',$Files=array()) {
$Data='';
for($i=0;$i<count($Files);$i++)
$Data.="\"{$Files[$i]}\" ";
exec("rar.exe a \"{$Output}\" {$Data}");
}
$Files=array('file1.ext','file2.ext','file3.ext');
RARFiles('asdf.rar',$Files);
// asdf.rar created.
?>
There's no error checking, so make sure you check that your expected RAR file exists before
doing anything with it.
Hopefully one day, PHP will be able to be allowed to create RAR files.
----
Server IP: 87.124.126.117
Probable Submitter: 109.155.237.34 (proxied: 109.155.237.34)
----
Manual Page -- http://www.php.net/manual/en/rar.examples.php
Edit -- https://master.php.net/note/edit/100963
Del: integrated -- https://master.php.net/note/delete/100963/integrated
Del: useless -- https://master.php.net/note/delete/100963/useless
Del: bad code -- https://master.php.net/note/delete/100963/bad+code
Del: spam -- https://master.php.net/note/delete/100963/spam
Del: non-english -- https://master.php.net/note/delete/100963/non-english
Del: in docs -- https://master.php.net/note/delete/100963/in+docs
Del: other reasons-- https://master.php.net/note/delete/100963
Reject -- https://master.php.net/note/reject/100963
Search -- https://master.php.net/manage/user-notes.php