Answer the question
In order to leave comments, you need to log in
Merging arrays by values?
Hello!
There are two arrays:
array(2) {
[0]=>
array(1) {
[431]=>
array(1) {
[0]=>
string(3) "914"
}
}
[1]=>
array(1) {
[432]=>
array(2) {
[0]=>
string(3) "922"
[1]=>
string(3) "923"
}
}
}
array(2) {
[0]=>914 and 922
[1]=>914 and 923
}
Answer the question
In order to leave comments, you need to log in
function joinByValue(array $arrays) {
$joined = [];
foreach ($arrays as $values) {
foreach ($values as $i=>$value) {
$joined[$i][] = $value;
}
}
return $joined;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question