array_key_exists

Supported Versions: PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8
Checks if the given key or index exists in the array
Alias key_exists
<?php array_key_exists(string|int|float|bool|resource|null $key, array $array): bool
<?php     public function hasCommandHandler($command)

    {

        return array_key_exists(get_class($command), $this->handlers);

    }
<?php     public function forget($key)

    {

        if (array_key_exists($key, $this->storage)) {

            unset($this->storage[$key]);



            return true;
<?php             $key = (string) $key;

        }



        return array_key_exists($key, $array);

    }
<?php     public function get($key, $default = null)

    {

        if (array_key_exists($key, $this->items)) {

            return $this->items[$key];

        }
<?php     public function getOrPut($key, $value)

    {

        if (array_key_exists($key, $this->items)) {

            return $this->items[$key];

        }
<?php                     default => $groupKey,

                };



                if (! array_key_exists($groupKey, $results)) {

                    $results[$groupKey] = new static;

                }
<?php         $keys = is_array($key) ? $key : func_get_args();



        foreach ($keys as $value) {

            if (! array_key_exists($value, $this->items)) {

                return false;

            }

        }
<?php         return new static(function () use ($iterator, &$iteratorIndex, &$cache) {

            for ($index = 0; true; $index++) {

                if (array_key_exists($index, $cache)) {

                    yield $cache[$index][0] => $cache[$index][1];



                    continue;
<?php         $count = count($keys);



        foreach ($this as $key => $value) {

            if (array_key_exists($key, $keys) && --$count == 0) {

                return true;

            }

        }
<?php         $keys = array_flip(is_array($key) ? $key : func_get_args());



        foreach ($this as $key => $value) {

            if (array_key_exists($key, $keys)) {

                return true;

            }

        }
<?php                 $keys = array_flip($keys);



                foreach ($this as $key => $value) {

                    if (array_key_exists($key, $keys)) {

                        yield $key => $value;



                        unset($keys[$key]);
<?php             $items = $this->getArrayableItems($items);



            foreach ($this as $key => $value) {

                if (array_key_exists($key, $items)) {

                    yield $key => $items[$key];



                    unset($items[$key]);
<?php     protected static function addDependencyForCallParameter($container, $parameter,

                                                            array &$parameters, &$dependencies)

    {

        if (array_key_exists($paramName = $parameter->getName(), $parameters)) {

            $dependencies[] = $parameters[$paramName];



            unset($parameters[$paramName]);
<?php             unset($parameters[$paramName]);

        } elseif (! is_null($className = Util::getParameterClassName($parameter))) {

            if (array_key_exists($className, $parameters)) {

                $dependencies[] = $parameters[$className];



                unset($parameters[$className]);
<?php             }

        } elseif ($parameter->isDefaultValueAvailable()) {

            $dependencies[] = $parameter->getDefaultValue();

        } elseif (! $parameter->isOptional() && ! array_key_exists($paramName, $parameters)) {

            $message = "Unable to resolve dependency [{$parameter}] in class {$parameter->getDeclaringClass()->getName()}";



            throw new BindingResolutionException($message);