我正在尝试将 2 个 db 结果组合在一起以获得如下所示的数组:
array(
0=>array(
'name'=>'John',
'title'=>'manager',
'email'=>'test',
'permission'=>'1',
'depart'=>'human resource'
),
1=>array(
'name'=>'Ted',
'title'=>'employee',
'email'=>'test2',
'permission'=>'2',
'depart'=>'human resource'
)
)
前 3 个元素来自 1 个返回的 DB 结果,后两个元素来自另一个 DB 结果。
$firstResults = DBCall::call(getName); //get name,title,email or John and Ted as an array
$secondResults = DBCall::call(getPermission); //get permission and depart as an array
//I then use array merge
$userResults=array_merge($firstResults ,$secondResults);
//but it will become
array(
0=>array(
'name'=>'John',
'title'=>'manager',
'email'=>'test'
),
1=>array(
'name'=>'Ted',
'title'=>'employee',
'email'=>'test2'
),
2=>array(
'permission'=>'1',
'depart'=>'human resource'
),
3=>array(
'permission'=>'2',
'depart'=>'human resource'
)
)
有什么办法可以归档我需要的结果吗?非常感谢!