I have a list of arrays (unknown amount), I need to merge all of them recursively.
So what I did what create an array of all of those arrays and pass them into this function:
function mergeMonth($array)
{
foreach($array as $date_string => $inner_array)
{
if(isset($temp_inner_array))
{
$temp_inner_array = array_merge_recursive($temp_inner_array,$inner_array);
}
else
{
$temp_inner_array = $inner_array;
}
}
return $temp_inner_array;
}
Most of the time this works just like I expected it to, but sometimes I get this error:
Warning: array_merge_recursive(): recursion detected in ... on line 89
Don't know why?
Any ideas?
Thanks!!
UPDATE
the structure is like this:
Array
(
[sales] => 301.5
[cost] =>
[repairs] => 0
[esps] => 0
[margin] => 301.5
[verified] => unverified
)
Which I then changed to:
Array
(
[sales] => 301.5
[cost] => 0
[repairs] => 0
[esps] => 0
[margin] => 301.5
[verified] => unverified
)
and that fixed the issue :)
Note anyone who can explain WHY my change fixed it, will get the accepted answer!