Combining array values in multilevel array

Posted by James Huckabone on Stack Overflow See other posts from Stack Overflow or by James Huckabone
Published on 2013-06-24T21:41:04Z Indexed on 2013/06/24 22:21 UTC
Read the original article Hit count: 167

Filed under:
|

I have an array like so:

array(
    'a'=>array(
        'a'=>3,
        'f'=>5,
        'sdf'=>0),
    't'=>array(
        'a'=>1,
        'f'=>2,
        'sdf'=>5),
    'pps'=>array(
        'a'=>1,
        'f'=>2,
        'sdf'=>3)
);

Notice how the sub-arrays are the same for each top-level array. If I wanted to, what's the easiest way to combine the sub-arrays so that I'm left with a one-dimensional array like:

array(
    'a'=>5,
    'f'=>9,
    'sdf'=>8
);

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays