0

I'm using a form where the pair of inputs can be added per automatic. One store value in select and the other as input

After submit I receive the values in array and I need to associate them together. So all key values [0] belongs together and all [1] and so on.

Array
(
[issue] => Array
    (
        [0] => 2
        [1] => 3
    )

[qty] => Array
    (
        [0] => 1
        [1] => 2
    )
)

How can I do this using PHP?

1
  • 1
    you want to sort array on the base of main key or sub key ? write down image code that what output you want Commented Oct 26, 2015 at 15:33

1 Answer 1

1

Just use a simple foreach loop.

$combined = array();
foreach ($_POST["issue"] as $k=>$v) {
  $combined[$k] = array($_POST["issue"][$k], $_POST["qty"][$k]);
}
print_r($combined);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.