How to flatten a 2d array of associative elements into a flat associative array
07:41 09 Mar 2010

My app is interacting with a web service that returns an indexed array of associative single-element arrays such as:

Array
(
    [0] => Array
        (
            [Price] => 1
        )
    [1] => Array
        (
            [Size] => 7
        )
    [2] => Array
        (
            [Type] => 2
        )
)

That's not a problem, but the problem is that the service keeps changing the index of those items, so in the next array the Price could be at 1 instead of 0.

How do I efficiently transform arrays like this into a single dimension array so I can access the variables through $var['Size'] instead of $var[1]['Size']?

php arrays multidimensional-array flatten merging-data