key
laravel/framework
Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Fetch a key from an array
key
(array|
object $array
):
int
|
string
|
null
foreach (
$this
->
items
as
$key
=>
$item
) {
$pair
=
$callback
(
$item
,
$key
);
$key
=
key
(
$pair
);
$value
=
reset
(
$pair
);
src/Illuminate/Collections/Collection.php
return;
}
$index
=
key
(
$matches
);
} else {
$index
=
array_search
(
$this
->
components
->
choice
(
'Which command would you like to run?'
,
$commandNames
),
$commandNames
);
}
src/Illuminate/Console/Scheduling/ScheduleTestCommand.php
{
$relation
=
array_shift
(
$path
);
$name
=
explode
(
':'
,
key
(
$relation
))[
0
];
if (
is_string
(
reset
(
$relation
))) {
$relation
=
reset
(
$relation
);
src/Illuminate/Database/Eloquent/Collection.php
);
}
return
app
(
'cache'
)->
put
(
key
(
$arguments
[
0
]),
reset
(
$arguments
[
0
]),
$arguments
[
1
] ??
null
);
}
}
src/Illuminate/Foundation/helpers.php
$extensions
=
$factory
->
getExtensions
();
$this
->
assertSame
(
'bar'
,
reset
(
$extensions
));
$this
->
assertSame
(
'foo'
,
key
(
$extensions
));
}
public function
testPrependedExtensionOverridesExistingExtensions
()
tests/View/ViewFactoryTest.php
$extensions
=
$factory
->
getExtensions
();
$this
->
assertSame
(
'bar'
,
reset
(
$extensions
));
$this
->
assertSame
(
'baz'
,
key
(
$extensions
));
}
public function
testComposersAreProperlyRegistered
()
tests/View/ViewFactoryTest.php