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 Answers1

0

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

foreach($results as $arr1){
    $results3[] = array_combine($keys, $arr1);
}