Multiple image upload each has caption

I’ve got the single image upload with a single caption and I’ve got the multiple image upload. I’d like to get the multiple image upload, each with a caption. Any help on combining these would be much appreciated. Here’s what I have so far:

if (array_key_exists('upload', $_POST)) {
  // convert the maximum size to KB
  $max = number_format(MAX_FILE_SIZE/1024, 1).'KB';
  
  // create an array of permitted MIME types
  $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png');
  
  // start the multiple upload
  foreach ($_FILES['image']['name'] as $number => $file) {
    // replace any spaces in the filename with underscores
	$file = str_replace(' ', '_', $file);

  // begin by assuming the file is unacceptable
  $sizeOK = false;
  $typeOK = false;
  
  // check that the file size is within the permitted size
    if ($_FILES['image']['size'][$number] > 0 || $_FILES['image']['size'][$number] <= MAX_FILE_SIZE) {
    $sizeOK = true;
   }
   
  // check that file is of a permitted MIME type
  foreach ($permitted as $type) {
      if ($type == $_FILES['image']['type'][$number]) {
      $typeOK = true;
      break;
      }
    }

the insert looks like this:

if ($sizeOK && $typeOK) { 
 // prepare an array of expected items
  $expected = array('filename', 'caption');
  // create database connection
  $conn = dbConnect('admin');
  // make $_POST data safe for insertion into database
  foreach ($_POST as $key => $value) {
    if (in_array($key, $expected)) {
	  ${$key} = mysql_real_escape_string($value);
	 }
   }
  // prepare the SQL query
  $sql = "INSERT INTO eventgallery (filename, caption)
          VALUES('$file', '$caption')";
  // process the query
  $result[] = mysql_query($sql) or die(mysql_error());
  // if successful, redirect to list of existing records
  if ($result) {
    //header('');
    }

With my form looking like this:

 <form action="" method="post" enctype="multipart/form-data" name="multiUpload" id="multiUpload">
    <p>
        <label for="image1">File 1:</label>
        <input type="file" name="image[]" id="image1" />
    </p>
    <p>
        <label for="image2">File 2:</label>
        <input type="file" name="image[]" id="image2" />
    </p>
    <p>
        <label for="image3">File 3:</label>
        <input type="file" name="image[]" id="image3" />
    </p>
        <p>
        <label for="image4">File 4:</label>
        <input type="file" name="image[]" id="image4" />
    </p>
        <p>
        <label for="image5">File 5:</label>
        <input type="file" name="image[]" id="image5" />
    </p>
        <p>
        <label for="caption">Caption:</label>
        <textarea name="caption" cols="60" rows="1" class="widebox" id="caption"></textarea>
    </p>
    <p>
        <input type="submit" name="upload" id="upload" value="Upload" />
    </p>
</form>

I thought I might be able to do somthing like this in the form, but I’m not getting it on in PHP.

    <p>
        <label for="image1">File 1:</label>
        <input type="file" name="image[]" id="image1" />
        <label for="caption">Caption:</label>
        <textarea name="caption[]" cols="60" rows="1" class="widebox" id="caption1"></textarea>
    </p>

And something like this for the php:

  foreach ($_FILES['caption']['name'] as $number => $caption) {
}

Any help would be really great. Please forgive my rookie skills.