下面是我的数组flightOne,一个多维数组,有两个数组作为数组元素[abc]和[efg]
array( 'flightOne' => Array
(
'abc' => Array
(
'2014-12-15' => Array
(
2 => Array
(
'no' => 11,
'name' => 'Firstname Secondname',
'dep_date' => '2014-12-15',
'flight' => 'flightOne',
'itinerary' => 'abc'
)
)
),
'efg' => Array
(
'2014-12-15' => Array
(
5 => Array
(
'no' => 11,
'name' => 'Firstname Secondname',
'dep_date' => '2014-12-15',
'flight' => 'flightOne',
'itinerary' => 'efg'
)
)
)
)
)
我想要的是删除[efg]数组键并与[abc]键组合, 因此,efg的内容将组合在[abc]的内容中,并给我一些类似的内容。
array('flightOne' => Array
(
'abc' => Array
(
'2014-12-15' => Array
(
2 => Array
(
'no' => 11,
'name' => 'Firstname Secondname',
'dep_date' => '2014-12-15',
'flight' => 'flightOne',
'itinerary' => 'abc'
),
5 => Array
(
'no' => 11,
'name' => 'Firstname Secondname',
'dep_date' => '2014-12-15',
'flight' => 'flightOne',
'itinerary' => 'efg'
)
)
)
)
)
答案 0 :(得分:0)
$array['flightOne']['abc']['2014-12-15'] =
array_merge($array['flightOne']['abc']['2014-12-15'],
$array['flightOne']['ghi']['2014-12-15']);
unset($array['flightOne']['ghi']);