I have 2 arrays first is data and 2nd is result array
i am trying to map result array with data array
so i used combine() method
but problem is that if i have same result then it map 1 item and skips remaining consider
first array($customersidurl)
[
19 => null,
20 => null,
21 => null,
24 => "31.4346084,74.2793016,12",
25 => null,
26 => "31.58834,74.37375"
]
second result array($shortest)
[
0 => 8532.8587780495,
1 => 8532.8587780495,
2 => 8532.8587780495,
3 => 18.831126689097,
4 => 8532.8587780495,
5 => 0.85071506409078
]
and my output is
[
"" => 8532.8587780495,
31.4346084,74.2793016,12 => 18.831126689097,
31.58834,74.37375 => 0.85071506409078,
]
it skipped 3 results. I don't want that skipping to happen. The code I used is
$customersidurl = Customer::whereIn('created_by', $adminot)
->get()
->pluck('location_url', 'id');
foreach ($customersidurl as $short) {
$shortest[] = $this->getsortedDistance($cords , $cords1 ,$short);
}
$combined = $customersidurl->combine($shortest);
can someone help me any other which can map each of elements with corresponding?
required output is
[
"" => 8532.8587780495,
"" => 8532.8587780495,
"" => 8532.8587780495,
31.4346084,74.2793016,12 => 18.831126689097,
"" => 8532.8587780495,
31.58834,74.37375 => 0.85071506409078
]