I have a multidimensional array that looks like such:
Array
(
[0] => Array
(
[email] => [email protected]
[added] => style-narcotics
)
[1] => Array
(
[email] => [email protected]
[added] => style-edm
)
[2] => Array
(
[email] => [email protected]
[added] => style-codeine
)
[3] => Array
(
[email] => [email protected]
[added] => style-food
)
)
I want to merge all the inner arrays combining the "added" key like such:
Array
(
[0] => Array
(
[email] => [email protected]
[added] => array(
[0]=>style-narcotics
[1]=>style-edm
)
)
[1] => Array
(
[email] => [email protected]
[added] => array(
[0]=>style-codeine
[1]=>style-food
)
)
I have tried merge array recursive in different forms and call_user_func but it doesnt cut it. Any advice? Thanks!
addedfromstringtoarray(add another nesting level) butarray_merge_recursive()doesn't do that. It doesn't change the structure of the arrays it receives as arguments. It just combines them. You have to iterate over the input array and create the desired output.