array_intersect_key

Supported Versions: PHP 5 >= 5.1.0, PHP 7, PHP 8
Computes the intersection of arrays using keys for comparison
<?php array_intersect_key(array $array, array ...$arrays): array
<?php     public static function only($array, $keys)

    {

        return array_intersect_key($array, array_flip((array) $keys));

    }
<?php     public function intersectByKeys($items)

    {

        return new static(array_intersect_key(

            $this->items, $this->getArrayableItems($items)

        ));

    }
<?php     protected function fillableFromArray(array $attributes)

    {

        if (count($this->getFillable()) > 0 && ! static::$unguarded) {

            return array_intersect_key($attributes, array_flip($this->getFillable()));

        }



        return $attributes;
<?php     protected function getArrayableItems(array $values)

    {

        if (count($this->getVisible()) > 0) {

            $values = array_intersect_key($values, array_flip($this->getVisible()));

        }



        if (count($this->getHidden()) > 0) {
<?php     public function only($keys)

    {

        return array_intersect_key($this->data, array_flip($keys));

    }
<?php     public function onlyHidden($keys)

    {

        return array_intersect_key($this->hidden, array_flip($keys));

    }
<?php         $fields = array_fill_keys($matches[0], null);



        $route->setBindingFields(array_replace(

            $fields, array_intersect_key($bindingFields, $fields)

        ));

    }
<?php             return [];

        }



        $parameters = array_intersect_key($matches, array_flip($parameterNames));



        return array_filter($parameters, function ($value) {

            return is_string($value) && strlen($value) > 0;
<?php     protected static function pathsForProviderAndGroup($provider, $group)

    {

        if (! empty(static::$publishes[$provider]) && ! empty(static::$publishGroups[$group])) {

            return array_intersect_key(static::$publishes[$provider], static::$publishGroups[$group]);

        }



        return [];
<?php             $this->passes();

        }



        $invalid = array_intersect_key(

            $this->data, $this->attributesThatHaveMessages()

        );



        $result = [];
<?php         $dataKeys = array_keys($data);



        if (empty(array_diff($parameters, $dataKeys))) {

            return new static(...array_intersect_key($data, array_flip($parameters)));

        }



        return Container::getInstance()->make(static::class, $data);