Jump to content

How to connect two posted values to eachother... ?


jani

Recommended Posts

Hello!

 

I have a directory layout processed from a (emulator)diskimage, i select files with a checkbox ("FILENUMBER") and _all_ FILENAMEs (not only selected) from that diskimage are POST:ed to another page.

 

What i want is to run the both POSTs against eachother, and return the filenames of selected files, see example below.

..so, i need to connect the FILENUMBERS connected to its respective FILENAME.

 

I did some testing here, and i kinda stumbled upon something i don't know where to start with.

 

 

"var_dump($_POST)" gives:

 

["FILENUMBER"]=>  array(2) { [0]=>  string(1) "1" [1]=>  string(1) "2"
["FILENAME"]=>  array(4) { [0]=>  string(24) "file1" [1]=>  string(24) "file2" [2]=>  string(24) "file3" [3]=>  string(24) "file4"

 

 

 

If i run these through "implode( ', ', $_POST['xxxxxxxxxx']") i get :

 

filenumber(s) selected: 1,2

filenames of all files: file1, file2, file3, file4

 

filename(s) of selected files: ?????? (here is where i need help)

 

 

TIA

/Jani

 

 

 

 

 

have a look into array_marge

 

Alternatively modify your form field names to be something like

 

<input type="text" name="file[0][numb]" />
<input type="text" name="file[0][name]" />

<input type="text" name="file[1][numb]" />
<input type="text" name="file[1][name]" />

<input type="text" name="file[2][numb]" />
<input type="text" name="file[2][name]" />

 

Now $_POST['file'] will be in this format:

Array
(
    [0] => Array
        (
            [name] => file1
            [numb] => 0001
        )

    [1] => Array
        (
            [name] => file2
            [numb] => 0002
        )

    [2] => Array
        (
            [name] => file3
            [numb] => 0003
        )

)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.