I have 2 arrays $projectsIds = [1,2]
and $usersIds = [1,2,3]
I have nasted foreach loop like this:
foreach($projectsIds as $projecID){
foreach($userIds as $userID){
$sync_array[$projecID] = array('user_id' => $userID);
}
}
dd($sync_array);
now I get result like this:
array:2 [ 1 => array:1 [ "user_id" => 1 ]
2 => array:1 [ "user_id" => 1 ]
]
Is possible to get result something like this:
array:2 [ 1 => array:1 [ "user_id" => 1 ]
1 => array:1 [ "user_id" => 2 ]
1 => array:1 [ "user_id" => 3 ]
2 => array:1 [ "user_id" => 1 ]
2 => array:1 [ "user_id" => 2 ]
2 => array:1 [ "user_id" => 3 ]
]