Laravel - Collections - Method Intersectbykeys

The intersectByKeys method removes any keys and their corresponding values from the original collection that are not present in the given array or collection:

    
    $collection = collect([
        'serial' => 'UX301', 'type' => 'screen', 'year' => 2009,
    ]);
    
    $intersect = $collection->intersectByKeys([
        'reference' => 'UX404', 'type' => 'tab', 'year' => 2011,
    ]);
    
    $intersect->all();
    
    // ['type' => 'screen', 'year' => 2009]