私は次の配列を持っています:
Array
(
[0] => Array
(
[id] => 23
[title] => jkl
)
[1] => Array
(
[id] => 478
[title] => lmn
)
[2] => Array
(
[id] => 22
[title] => pqr
)
[3] => Array
(
[id] => 21
[title] => abc
)
)
同じことが2番目の配列です:
Array
(
[0] => Array
(
[id] => 103
[title] => Activities
)
[1] => Array
(
[id] => 76
[title] => Top 10 Ideas
)
[2] => Array
(
[id] => 9
[title] => Best Shopping Areas
)
)
最初の配列の数が3未満の場合、最初の配列を2番目の配列に追加したいので、配列プッシュ関数を使用して次のようにしました:
if (count($secondArr) < 3) {
echo "<pre>";
echo array_push($secondArr, $firstArr);
print_r($result);
exit;
}
array_push の後、このような配列が表示されます (多次元)
Array
(
[0] => Array
(
[id] => 76
[title] => Activities
)
[1] => Array
(
[id] => 103
[title] => Top 10 Ideas
)
[2] => Array
(
[id] => 9
[title] => Best Shopping Areas
)
[3] => Array
(
[0] => Array
(
[id] => 23
[title] => jkl
)
[1] => Array
(
[id] => 478
[title] => lmn
)
[2] => Array
(
[id] => 22
[title] => pqr
)
[3] => Array
(
[id] => 21
[title] => abc
)
)
)
私はこのようにしたくない(多次元)。キー4,5などを追加したい。はいの場合、どのように可能ですか?
ありがとう。