Cannot get my array from my form right

Hello everyone,

I am not sure where to put this so I post this here.
Were building a small intern script that duplicates files but it needs a form to post the correct data.

So when I enter my order number I get a form with files which looks like this :

Now when I save the form I get this :

array(2) {
  ["dupliceer"]=>
  array(10) {
    [1]=>
    array(2) {
      ["file"]=>
      string(40) "y:/1609998 Vomar/studio/test kopie 2.pdf"
      ["aantal_keer"]=>
      string(1) "1"
    }
    [2]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [3]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [4]=>
    array(2) {
      ["file"]=>
      string(40) "y:/1609998 Vomar/studio/test kopie 5.pdf"
      ["aantal_keer"]=>
      string(1) "2"
    }
    [5]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [6]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [7]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [8]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [9]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
    [10]=>
    array(1) {
      ["aantal_keer"]=>
      string(0) ""
    }
  }
  ["submit"]=>
  string(8) "verstuur"
}

I only want the filled in files, does this mean I need to unset all empty arrays ? ( yes there is something in it but it is empty to. )

Best regards,
Wouter/

What does the HTML look like? The most likely cause is if you are numbering the array entries in the HTML.

This is how my html looks like.
I do keep track of the count in my code.

get rid of the <?php echo $i; ?> from each checkbox tag - only those that are entered will then be sent.

Sorry for the late reply, but I have notices some issues.
If I take away the <?php echo $; ?> I will get the following array which doesn’t make any sense :

array(1) {
  [4]=>
  array(1) {
    ["aantal_keer"]=>
    string(1) "2"
  }
}

So a problem now is, where is my file out of the sudden ?
I changed the checkbox to a input hidden with the filepath+name as value.
But it doesn’t get posted trough which is weird.

only checked checkboxes will be transfered.

I changed the checkbox to a hidden input field ( which normally also transfers over. )
But now it can not be found somehow.

Fixed it by troing a sort after I used my inset.

So I did keep the count on the html.
Unsetted when a specific field is empty and after running trough that I called a the sort function.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.