Есть код:
$asArray = Array (
"KEY0" => "A",
"KEY1" => Array (
"key1_0" => "aa",
"key1_1" => "bb",
"key1_2" => Array (
"KeY1_0_0" => "AAA_0",
"KeY1_0_1" => "BBB_0",
"KeY1_0_2" => "CCC_0",
"KeY1_0_3" => "DDD_0",
"KeY1_0_4" => "EEE_0",
"KeY1_0_5" => "FFF_0",
"KeY1_0_6" => "GGG_0",
),
"key1_3" => Array (
"KeY1_0_0" => "AAA_1",
"KeY1_0_1" => "BBB_1",
"KeY1_0_2" => "CCC_1",
"KeY1_0_3" => "DDD_1",
"KeY1_0_4" => "EEE_1",
"KeY1_0_5" => "FFF_1",
"KeY1_0_6" => "GGG_1",
),
"key1_4" => Array (
"KeY1_0_0" => "AAA_2",
"KeY1_0_1" => "BBB_2",
"KeY1_0_2" => "CCC_2",
"KeY1_0_3" => "DDD_2",
"KeY1_0_4" => "EEE_2",
"KeY1_0_5" => "FFF_2",
"KeY1_0_6" => "GGG_2",
),
"key1_5" => "cc",
),
"KEY2" => "B",
"KEY4" => "C",
);
function OutputArray ($saArray) {
$asKeY = array();
$asKeYoutput = array();
foreach ($saArray as $sKeyArray => $sValueArray) {
if (is_array ($sValueArray)) {
OutputArray ($sValueArray);
}
else {
//echo ($sKeyArray.' = '.$sValueArray.'<br>');
if ($sKeyArray == 'KeY1_0_0') {
$asKeY[] = $sValueArray;
echo ('sKeY0 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_1') {
$asKeY[] = $sValueArray;
echo ('sKeY1 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_2') {
$asKeY[] = $sValueArray;
echo ('sKeY2 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_3') {
$asKeY[] = $sValueArray;
echo ('sKeY3 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_4') {
$asKeY[] = $sValueArray;
echo ('sKeY4 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_5') {
$asKeY[] = $sValueArray;
echo ('sKeY5 = '.$sValueArray.'<br>');
};
if ($sKeyArray == 'KeY1_0_6') {
$asKeY[] = $sValueArray;
echo ('sKeY6 = '.$sValueArray.'<br>');
};
};
};
$asKeYoutput = $asKeY;
// var_dump ($asKeY);
// echo ('<br>----- '.$asKeY.' Массив: $asKeY -----<hr>');
echo ('<br><br>');
var_dump ($asKeYoutput);
echo ('<hr>');
// echo ('<br>----- '.$asKeYoutput.' Массив: $asKeYoutput -----<hr>');
return $asKeYoutput;
}
$asOutputArray = OutputArray ($asArray);
echo '<hr>';
var_dump ($asOutputArray);
echo '<hr>';
Получаю массивы:
array(7) { [0]=> string(5) "AAA_0" [1]=> string(5) "BBB_0" [2]=> string(5) "CCC_0" [3]=> string(5) "DDD_0" [4]=> string(5) "EEE_0" [5]=> string(5) "FFF_0" [6]=> string(5) "GGG_0" } array(7) { [0]=> string(5) "AAA_1" [1]=> string(5) "BBB_1" [2]=> string(5) "CCC_1" [3]=> string(5) "DDD_1" [4]=> string(5) "EEE_1" [5]=> string(5) "FFF_1" [6]=> string(5) "GGG_1" } array(7) { [0]=> string(5) "AAA_2" [1]=> string(5) "BBB_2" [2]=> string(5) "CCC_2" [3]=> string(5) "DDD_2" [4]=> string(5) "EEE_2" [5]=> string(5) "FFF_2" [6]=> string(5) "GGG_2" }
Вопрос как их "склеить", что бы получить новый ассоциативный массив вида:
array ( [0] => "первый полученный массив", [1] => "второй полученный массив", [2] => "третий полученный массив", [3] => "четвертый полученный массив",)