ホームページ >バックエンド開発 >PHPチュートリアル >PHPで2つの配列をマージする方法
PHP で 2 つの配列をマージする方法
配列 1:
$a_array = 配列
(
[0] => 配列
(
[plan_id] => 1
[ad_img_url] => http://www.adsload.com/assets/ad1.jpg
)
[1] => 配列
(
[plan_id] => 2
[ad_img_url] => http://www.adsload.com/assets/ad2.jpg
)
[2] => 配列
(
[plan_id] => 3
[ad_img_url] => http://www.adsload.com/assets/ad3.jpg
)
)
配列 2:
$b_array = 配列
(
[0] => 配列
(
[plan_id] => 1
[ad_url] => http://www.baidu.com/
)
[1] => 配列
(
[plan_id] => 2
[ad_url] => http://www.baidu.com/
)
[2] => 配列
(
[plan_id] => 3
[ad_url] => http://www.baidu.com/
)
)
マージ後:
$result_array = 配列
(
[0] => 配列
(
[plan_id] => 1
[ad_img_url] => http://www.adsload.com/assets/ad1.jpg
[広告URL] => http://www.baidu.com/
)
[1] => 配列
(
[plan_id] => 2
[ad_img_url] => http://www.adsload.com/assets/ad2.jpg
[広告URL] => http://www.baidu.com/
)
[2] => 配列
(
[plan_id] => 3
[ad_img_url] => http://www.adsload.com/assets/ad3.jpg
[広告URL] => http://www.baidu.com/