0

I have the following generated by a for loop (the actual list is longer),

Array
(
    [0] => Array
        (
            [0] => apple
            [1] => 3
        )

    [1] => Array
        (
            [0] => orange
            [1] => 1
        )
)

How do I get the following with the keys (name,number) added?

Array
(
    [0] => Array
        (
            [name] => apple
            [number] => 3
        )

    [1] => Array
        (
            [name] => orange
            [number] => 1
        )
)

1 Answer 1

0

I found the answer from another post. change inner key in multidimensional array php

foreach($results as $arr1){
    $results3[] = array_combine($keys, $arr1);
}
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.