samedi 28 février 2015

What mistake I'm making in formation of new array so the index is not being generated?


Vote count:

0




I've following $_POST array :



Array
(
[fileName] => Array
(
[0] => 8.png
[1] => 2_OnClick_OK.jpg
)

[fileLink] => Array
(
[0] => http://ift.tt/1AmgtNr
[1] => http://ift.tt/1BpSous
)

[Submit] => Submit File
)


I got the above output after execution of following statement:



print_r($_POST); die;//Code to print the $_POST array


Now from the above $_POST array I've to create a new desired array which should be structured as follows after printing it:



Array
(
[8.png] => Array
(
[0] => http://ift.tt/1AmgtNr
)
[2_OnClick_OK.jpg]
(
[0] => http://ift.tt/1BpSous
)

)


For this I tried following code.



$request_Arr = array_combine ( $_POST['fileName'], $_POST['fileLink'] );


After execution of above code if I print the array $request_Arr it prints following output:



Array (
[8.png] => http://ift.tt/1zt9jGS
[2_OnClick_OK.jpg] => http://ift.tt/1AHTrp8
)


So my issue is it's not generating the [0] index key for inner array. I want the new array with [0] index key present as follows :



Array
(
[8.png] => Array
(
[0] => http://ift.tt/1AmgtNr
)
[2_OnClick_OK.jpg]
(
[0] => http://ift.tt/1BpSous
)

)


Can someone please correct my mistake and help me in creating an array in desired format?


Thanks in advance.



asked 21 secs ago







What mistake I'm making in formation of new array so the index is not being generated?

Aucun commentaire:

Enregistrer un commentaire