I have a function that returns an array like this
Array
(
[0] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
[1] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
)
I need to add each element above to another array like this
Array
(
[0] => Array
(
[name] => Name
[value] => Johan
)
[1] => Array
(
[name] => Address
[value] => Mayfair Lane
)
)
The thing is I need the first array elements inserted at the same level of the 2nd array, IN THE MIDDLE, between the 2nd arrays first and second elements.
Array
(
[0] => Array
(
[name] => Name
[value] => Johan
)
[1] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
[2] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
)
[3] => Array
(
[name] => Address
[value] => Mayfair Lane
)
)
The problem is if I just add the first array as is, in the center (using its own variable), it adds it like this
Array
(
[0] => Array
(
[name] => Name
[value] => Johan
)
[1] => Array
(
[0] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
[1] => Array
(
[name] => Percent
[attributes] => Array
(
[Percent] => 50
)
)
)
[2] => Array
(
[name] => Address
[value] => Mayfair Lane
)
)
I've looked at array_merge but ofcourse, I cannot specify the 2nd array elements go in the middle as I need.
array_splicein there ?