So I have 2 arrays like so:
$a = array(array('1','2','3'), array('hello','darkness','my'));
$b = array(array('4','5','6'), array('old','friend','I'));
Now I want to merge the subarrays respectively:
$result = array(array_merge($a[0],$b[0]),array_merge($a[1],$b[1])));
Resulting in:
#vardump($result)
array(2) {
[0]=>
array(6) {
[0]=>
string(1) "1"
[1]=>
string(1) "2"
[2]=>
string(1) "3"
[3]=>
string(1) "4"
[4]=>
string(1) "5"
[5]=>
string(1) "6"
}
[1]=>
array(6) {
[0]=>
string(5) "hello"
[1]=>
string(8) "darkness"
[2]=>
string(2) "my"
[3]=>
string(3) "old"
[4]=>
string(6) "friend"
[5]=>
string(1) "I"
}
}
Well this works... but it just looks clumsy and it isn't a good solution if there would be a variable amount of subarrays I need to merge. Is there a build-in function for this kind of operation (or a more "acceptable" way to do this)?