Skip to main content
deleted 33 characters in body
Source Link
AbraCadaver
  • 79.2k
  • 7
  • 75
  • 91

I've been struggling with this issue for the past couple of days now; I'venow. I've looked around StackOverflow but have only encountered topics where the solution relies on all the keys in the multidimensional array are the same.

If this questions already been answered sorry for the duplicate...

My issue is merging a multidimensional array based on a similar key and value.

Current Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 
    ) 
    [1] => Array ( 
        [y] => 2015-10-17 [b] => 1 
    ) 
    [2] => Array (
        [y] => 2015-10-17 [d] => 1 
    ) 
    [3] => Array ( 
        [y] => 2015-10-17 [a] => 6 
    ) 
    [4] => Array ( 
        [y] => 2015-10-18 [e] => 2 
    ) 
    [5] => Array ( 
        [y] => 2015-10-18 [c] => 1 
    ) 
    [6] => Array ( 
        [y] => 2015-10-18 [b] => 1 
    ) 
    [7] => Array ( 
        [y] => 2015-10-20 [c] => 1 
    ) 
    [8] => Array ( 
        [y] => 2015-10-20 [b] => 2 
    ) 
)

Desired Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 [b] => 1 [d] => 1 [a] => 6 
    ) 
    [1] => Array ( 
        [y] => 2015-10-18 [e] => 2 [c] => 1 [b] => 1 
    ) 
    [2] => Array ( 
        [y] => 2015-10-20 [c] => 1 [b] => 2 
    ) 
)

)

I've been struggling with this issue for the past couple of days now; I've looked around StackOverflow but have only encountered topics where the solution relies on all the keys in the multidimensional array are the same.

If this questions already been answered sorry for the duplicate...

My issue is merging a multidimensional array based on a similar key and value.

Current Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 
    ) 
    [1] => Array ( 
        [y] => 2015-10-17 [b] => 1 
    ) 
    [2] => Array (
        [y] => 2015-10-17 [d] => 1 
    ) 
    [3] => Array ( 
        [y] => 2015-10-17 [a] => 6 
    ) 
    [4] => Array ( 
        [y] => 2015-10-18 [e] => 2 
    ) 
    [5] => Array ( 
        [y] => 2015-10-18 [c] => 1 
    ) 
    [6] => Array ( 
        [y] => 2015-10-18 [b] => 1 
    ) 
    [7] => Array ( 
        [y] => 2015-10-20 [c] => 1 
    ) 
    [8] => Array ( 
        [y] => 2015-10-20 [b] => 2 
    ) 
)

Desired Output:

Array ( 
[0] => Array ( 
    [y] => 2015-10-17 [c] => 1 [b] => 1 [d] => 1 [a] => 6 
) 
[1] => Array ( 
    [y] => 2015-10-18 [e] => 2 [c] => 1 [b] => 1 
) 
[2] => Array ( 
    [y] => 2015-10-20 [c] => 1 [b] => 2 
) 

)

I've been struggling with this issue for the past couple of days now. I've looked around StackOverflow but have only encountered topics where the solution relies on all the keys in the multidimensional array are the same.

My issue is merging a multidimensional array based on a similar key and value.

Current Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 
    ) 
    [1] => Array ( 
        [y] => 2015-10-17 [b] => 1 
    ) 
    [2] => Array (
        [y] => 2015-10-17 [d] => 1 
    ) 
    [3] => Array ( 
        [y] => 2015-10-17 [a] => 6 
    ) 
    [4] => Array ( 
        [y] => 2015-10-18 [e] => 2 
    ) 
    [5] => Array ( 
        [y] => 2015-10-18 [c] => 1 
    ) 
    [6] => Array ( 
        [y] => 2015-10-18 [b] => 1 
    ) 
    [7] => Array ( 
        [y] => 2015-10-20 [c] => 1 
    ) 
    [8] => Array ( 
        [y] => 2015-10-20 [b] => 2 
    ) 
)

Desired Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 [b] => 1 [d] => 1 [a] => 6 
    ) 
    [1] => Array ( 
        [y] => 2015-10-18 [e] => 2 [c] => 1 [b] => 1 
    ) 
    [2] => Array ( 
        [y] => 2015-10-20 [c] => 1 [b] => 2 
    ) 
)
Source Link
Rahh
  • 109
  • 12

Merging Multdimensional Array with similiar Key PHP

I've been struggling with this issue for the past couple of days now; I've looked around StackOverflow but have only encountered topics where the solution relies on all the keys in the multidimensional array are the same.

If this questions already been answered sorry for the duplicate...

My issue is merging a multidimensional array based on a similar key and value.

Current Output:

Array ( 
    [0] => Array ( 
        [y] => 2015-10-17 [c] => 1 
    ) 
    [1] => Array ( 
        [y] => 2015-10-17 [b] => 1 
    ) 
    [2] => Array (
        [y] => 2015-10-17 [d] => 1 
    ) 
    [3] => Array ( 
        [y] => 2015-10-17 [a] => 6 
    ) 
    [4] => Array ( 
        [y] => 2015-10-18 [e] => 2 
    ) 
    [5] => Array ( 
        [y] => 2015-10-18 [c] => 1 
    ) 
    [6] => Array ( 
        [y] => 2015-10-18 [b] => 1 
    ) 
    [7] => Array ( 
        [y] => 2015-10-20 [c] => 1 
    ) 
    [8] => Array ( 
        [y] => 2015-10-20 [b] => 2 
    ) 
)

Desired Output:

Array ( 
[0] => Array ( 
    [y] => 2015-10-17 [c] => 1 [b] => 1 [d] => 1 [a] => 6 
) 
[1] => Array ( 
    [y] => 2015-10-18 [e] => 2 [c] => 1 [b] => 1 
) 
[2] => Array ( 
    [y] => 2015-10-20 [c] => 1 [b] => 2 
) 

)