0
I got the following code
$teste1 = array(
1 => array( 1 => 'teste1', 2 => 'teste2', 3 => 'teste3'),
2 => array(3 => 'teste4', 5 => 'teste5')
);
$teste2 = array(
1 => array( 3 => 'teste6', 4 => 'teste7')
);
function uniqKeys($arr1, $arr2){
if(empty($arr1)){
return $arr2;
}
foreach ($arr1 as $key1 => $value1) {
foreach ($arr2 as $key2 => $value2) {
if ($key2 == $key1) {
foreach($value2 as $key3 => $value3) {
array_push($arr1[$key1], $value3);
}
}
}
}
return $arr1;
}
print_r(uniqKeys($teste1, $teste2));
outworking
Array
(
[1] => Array
(
[1] => teste1
[2] => teste2
[3] => teste3
[4] => teste6
[5] => teste7
)
[2] => Array
(
[3] => teste4
[5] => teste5
)
)
I wonder if there is a cleaner way to make this junction, I did a traditional looping, but as it is a lot of data, will require a lot of server.
Exactly that, thank you!
– Felipe Duarte