新しいパスごとに新しい配列を作成する do-while ループがあります。
do-whileループ:
$i = 0;
do {
// Create an array of data from the response
$array_data = array();
foreach ($response['data'] as $data) {
$created_time = $data['created_time'];
$thumbnail = $data['images']['thumbnail']['url'];
$tags_name = $get_TagIMG;
$array_data[] = array
(
'DATE_PIC' => $created_time,
'LINK_PIC' => $thumbnail,
'TAG_PIC' => $tags_name,
);
}
$i++;
} while ($i < 5);
サイクルの終了後、次のような 5 つの配列を取得します。
Array (
[0] => Array ( [DATE_PIC] => 1380488912 [LINK_PIC] => http://distilleryimage0.s3.amazonaws.com/4c39144e294b11e3bef022000a1f9245_5.jpg [TAG_PIC] => pricelessmoscow )
)
Array (
[1] => Array ( [DATE_PIC] => 1380489222 [LINK_PIC] => http://distilleryimage5.s3.amazonaws.com/04ca9032294c11e3b53822000a1f96e6_5.jpg [TAG_PIC] => pricelessmoscow )
)
Array (
[2] => Array ( [DATE_PIC] => 1380492460 [LINK_PIC] => http://distilleryimage9.s3.amazonaws.com/8e755dd8295311e3a53722000aeb43de_5.jpg [TAG_PIC] => pricelessmoscow )
)
Array (
[3] => Array ( [DATE_PIC] => 1380718591 [LINK_PIC] => http://distilleryimage5.s3.amazonaws.com/0f8bcf142b6211e3982822000ae90f30_5.jpg [TAG_PIC] => pricelessmoscow )
)
Array (
[4] => Array ( [DATE_PIC] => 1380717412 [LINK_PIC] => http://distilleryimage7.s3.amazonaws.com/507c69fa2b5f11e3a7d422000a9e0846_5.jpg [TAG_PIC] => pricelessmoscow )
)
質問: これらの配列を 1 つに結合するにはどうすればよいですか?
結果は次のようになります。
Array (
[0] => Array ( [DATE_PIC] => 1380488912 [LINK_PIC] => http://distilleryimage0.s3.amazonaws.com/4c39144e294b11e3bef022000a1f9245_5.jpg [TAG_PIC] => pricelessmoscow )
[1] => Array ( [DATE_PIC] => 1380489222 [LINK_PIC] => http://distilleryimage5.s3.amazonaws.com/04ca9032294c11e3b53822000a1f96e6_5.jpg [TAG_PIC] => pricelessmoscow )
[2] => Array ( [DATE_PIC] => 1380492460 [LINK_PIC] => http://distilleryimage9.s3.amazonaws.com/8e755dd8295311e3a53722000aeb43de_5.jpg [TAG_PIC] => pricelessmoscow )
[3] => Array ( [DATE_PIC] => 1380718591 [LINK_PIC] => http://distilleryimage5.s3.amazonaws.com/0f8bcf142b6211e3982822000ae90f30_5.jpg [TAG_PIC] => pricelessmoscow )
[4] => Array ( [DATE_PIC] => 1380717412 [LINK_PIC] => http://distilleryimage7.s3.amazonaws.com/507c69fa2b5f11e3a7d422000a9e0846_5.jpg [TAG_PIC] => pricelessmoscow )
)