Going through foreach loop for filter on my site I get array back like this:
Array
(
[21] => Blau
[24] => Azul
[28] => Blue
)
By choosing next filter another array will be created:
Array
(
[21] => Grün
[24] => Verde
[28] => Green
)
and so on...
What I what to do is merge values of these arrays on same keys. So it have to be look like this:
Array
(
[21] => Blau-Grün
[24] => Azul-Verde
[28] => Blue-Green
)
It worked with Uchiha's code. I made some changed inside my loop:
foreach (...){
//some logic before
$array[] = array();
$i = 0;
foreach($array as $k => $v){
$i++;
foreach($array[$k] as $key => $value){
if(array_key_exists($key, $array[$i])){
$result[$key] = $value . '-' . $array[$i][$key];
}
}
}
echo '<pre>' . print_r($result,true) . '</pre>';
}
&array1and$array2etc). Each of these arrays will be produced while foreach loop and saved in same varaiable.