Level 104
The simple answer is array_merge to put your two associative arrays together
However, you surely can make a single query with a join?
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have an array that contain a name like that 'name' => 'user' so what i would to do is that i want to push two object to the same array, i want that array look like that ...
['name' => 'user'
'id' => 2
'role' => 'admin']
I have to do it this way because I get the id and the role from another table.
my code:
$calender_config_info = auth()->user()->business->calender_config;
$id = auth()->user()->business->id;
$employeeInfo = Employee::where('business_id', $id)->get();
foreach($employeeInfo as $info){
$employeeInfo = array(
'id' => $info['id'],
'role' => $info['role'],
);
}
//dd($employeeInfo);
$employee_list = [];
foreach ($calender_config_info as $info) {
$employee = array(
'name' => $info['info']['Employee']
);
array_push($employee_list, $employee);
}
//dd($employee_list);
so i have the values but i don't know how to push it in the right way.
The simple answer is array_merge to put your two associative arrays together
However, you surely can make a single query with a join?
Please or to participate in this conversation.