我有2个db查询从db返回值,这是最简单的方法。是否有可以执行此操作的PHP函数或是否必须使用循环?
$names = array(
'det-1' => array('foo'),
'det-2' => array('bar'),
'det-3' => array('doe')
);
$emails = array(
'det-1' => array('foo@gmail.com'),
'det-2' => array('bar@gmail.com'),
'det-3' => array('doe@gmail.com')
);
//结果
$details = array(
'det-1' => array('foo', 'foo@gmail.com')
'det-2' => array('bar', 'bar@gmail.com')
'det-3' => array('doe', 'doe@gmail.com')
);
答案 0 :(得分:2)
php > print_r(array_merge_recursive($names, $emails));
Array
(
[det-1] => Array
(
[0] => foo
[1] => foo@gmail.com
)
[det-2] => Array
(
[0] => bar
[1] => bar@gmail.com
)
[det-3] => Array
(
[0] => doe
[1] => doe@gmail.com
)
)
答案 1 :(得分:0)
$newArray = array_merge_recursive($names, $emails);