Question: I have a problem here, I want to combine 2 arrays into 1, I've tried using array\_merge from php, and merge () from laravel but nothing works 
//$plucked is EAV database

```
$vendor = Vendor::find($id)->toArray();
        $vendor_detail = Vendor_detail::where('vendor_id',$id)->get();
        $plucked = $vendor_detail->pluck('vendor_name','vendor_value');

        $merged = array_merge($plucked, $vendor);

        // $merged = $vendor->merge($plucked)->all(); 
        dd($merged);

```

I think because the array is different, there array $plucked

```
#items: array:10 [▼
    "user_email" => "cobaupdatelagi@gmail.com"

  ]

```

and there my array in $vendor

```

array:15 [▼
  "vendor_id" => 39
  "province" => "ACEH"

]

```

the output that I want

```
$somearray =[
   "vendor_id" => 39
  "province" => "ACEH"
  "user_email" => "cobaupdatelagi@gmail.com"

]

```

Answer: 
Your `$vendor` is one associative array while `$plucked` is an array of arrays. Even if it has only one item it will be of index zero so you need to loop through `$plucked` and merge for each one.

```
$vendor = Vendor::find($id)->toArray();
$vendor_detail = Vendor_detail::where('vendor_id',$id)->get();
$plucked = $vendor_detail->pluck('vendor_name','vendor_value');

$merged = [];
foreach($plucked as $p){
    $merged[] = array_merge($p, $vendor);
}
dd($merged);

```
I think you should use database join to get faster results.

```
$vendor = Vendor::join('vendor_details', 'vendors.id', '=', 'vendor_details.vendor_id')
    ->select('vendors.*', 'vendor_name','vendor_value')
    ->where('id', $id)
    ->first();

if ($vendor)  {
    $vendor = $vendor->toArray();
}

```