key

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Fetch a key from an array
<?php key(array|object $array): int|string|null
<?php         foreach ($this->items as $key => $item) {

            $pair = $callback($item, $key);



            $key = key($pair);



            $value = reset($pair);
<?php         $field = 'answer';



        if (is_array($rules) && ! array_is_list($rules)) {

            [$field, $rules] = [key($rules), current($rules)];

        }



        return $this->getPromptValidatorInstance(
<?php                 return;

            }



            $index = key($matches);

        } else {

            $index = $this->getSelectedCommandByIndex($commandNames);

        }
<?php     {

        $relation = array_shift($path);



        $name = explode(':', key($relation))[0];



        if (is_string(reset($relation))) {

            $relation = reset($relation);
<?php             );

        }



        return app('cache')->put(key($arguments[0]), reset($arguments[0]), $arguments[1] ?? null);

    }

}
<?php         $extensions = $factory->getExtensions();

        $this->assertSame('bar', reset($extensions));

        $this->assertSame('foo', key($extensions));

    }



    public function testPrependedExtensionOverridesExistingExtensions()
<?php         $extensions = $factory->getExtensions();

        $this->assertSame('bar', reset($extensions));

        $this->assertSame('baz', key($extensions));

    }



    public function testCallCreatorsDoesDispatchEventsWhenIsNecessary()
<?php         return $this->executeStatement(

            'DELETE FROM ' . $table . ' WHERE ' . implode(' AND ', $conditions),

            $values,

            is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types

        );

    }
<?php         $this->addCriteriaCondition($criteria, $columns, $values, $conditions);



        if (is_string(key($types))) {

            $types = $this->extractTypeValues($columns, $types);

        }
<?php             'INSERT INTO ' . $table . ' (' . implode(', ', $columns) . ')' .

            ' VALUES (' . implode(', ', $set) . ')',

            $values,

            is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types

        );

    }
<?php     private function _bindTypedValues(DriverStatement $stmt, array $params, array $types): void

    {


        if (is_int(key($params))) {

            $bindIndex = 1;



            foreach ($params as $key => $value) {
<?php     private function needsArrayParameterConversion(array $params, array $types): bool

    {

        if (is_string(key($params))) {

            return true;

        }
<?php                 foreach ($sqlPart as $part) {

                    $this->sqlParts[$sqlPartName][] = $part;

                }

            } elseif ($isArray && is_array($sqlPart[key($sqlPart)])) {

                $key                                  = key($sqlPart);

                $this->sqlParts[$sqlPartName][$key][] = $sqlPart[$key];

            } elseif ($isMultiple) {
<?php                     $this->sqlParts[$sqlPartName][] = $part;

                }

            } elseif ($isArray && is_array($sqlPart[key($sqlPart)])) {

                $key                                  = key($sqlPart);

                $this->sqlParts[$sqlPartName][$key][] = $sqlPart[$key];

            } elseif ($isMultiple) {

                $this->sqlParts[$sqlPartName][] = $sqlPart;
<?php         $offset = 0;



        while (($handler = current($patterns)) !== false) {

            if (preg_match('~\G' . key($patterns) . '~s', $sql, $matches, 0, $offset) === 1) {

                $handler($matches[0]);

                reset($patterns);