Zipstream - PHP在输出标头之前获取查询字符串

I'm using this to create on-the-fly zipping and delivery of files from an amazon bucket:

For example this can be passed to the file: index.php?q=movie1.m4v|movie2.m4v

I've used this: http://pablotron.org/software/zipstream-php/ which works good.

But the following code doesn't work:

require 'zipstream.php';

$q = $_GET["q"];
$files = explode("|", $q);


foreach ($files as $i) {
  $zip->add_file_from_path($files[i], "http://[amazon bucket link here]" + $files[i]);

}

$zip->finish();

This doesn't work though. It gives me an empty zip file.

When I do it manually, it works fine:

$zip->add_file_from_path('movie1.m4v', 'http://[amazon bucket]/movie1.m4v');

I believe the headers are sent before the querystring is read, which messes up the following code in my php file, right? How do I get around this?

thanks

Solved NOW should be $files[$i] and . for cocatenation. Not $files[i] and + . Javascript coding habits confused me

Working version:

$q = $_GET["q"];
$files = explode("|", $q);

# load zipstream class
require 'zipstream.php';

$zip = new ZipStream('download.zip');


for ($i = 0; $i < count($files); ++$i) {
    $zip->add_file_from_path($files[$i], "http://[amazon bucket]" . $files[$i]);
}

$zip->finish();