A::pluck()
Plucks a single column from an array
A::pluck(array $array, string $key): list
Parameters
| Name | Type | Default |
|---|---|---|
| $arrayrequired | array |
no default value |
| $keyrequired | string |
no default value |
Return type
list<mixed>
Parent class
Examples
$array[] = [
'id' => 1,
'username' => 'homer',
];
$array[] = [
'id' => 2,
'username' => 'marge',
];
$array[] = [
'id' => 3,
'username' => 'lisa',
];
var_dump(A::pluck($array, 'username'));
// result: ['homer', 'marge', 'lisa'];