0

I searched the most topics and couldn't find something that helps me out.

I have the following 2 arrays from form submit

Array
(
    [0] => FDS
    [1] => FSS
)
Array
(
    [0] => [email protected]
    [1] => 0123456789
)

and I need to combine the values from the first array with the values of the second array and make a custom third array that should look like this:

Array
        (
            [0] => Array
                (
                    [code] => FDS
                    [info] => [email protected]
                )

            [1] => Array
                (
                    [code] => SM2
                    [info] => 0123456789
                )

        )

The html form inputs looks like this:

<input type="checkbox" name="code[]" value="FDS">
<input id="flexDeliveryEmailInput" type="text" name="info[]">
<input id="flexDeliverySMS" type="checkbox" name="code[]" value="FSS">
<input type="text" name="info[]">
0

1 Answer 1

2

Try the following form inputs instead:

<input type="checkbox" name="data[0][code]" value="FDS">
<input id="flexDeliveryEmailInput" type="text" name="data[0][info]">
<input id="flexDeliverySMS" type="checkbox" name="data[1][code]" value="FSS">
<input type="text" name="data[1][info]">

This will provide the merged array as you want it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.