This should work for you:
Just pass NULL
as second argument to array_column()
to get the full array back as values and use $column
as third argument for the keys.
$result = array_column($arr, NULL, $column);
example input/output:
$arr = [
["a" => 1, "b" => 2, "c" => 3],
["a" => 4, "b" => 5, "c" => 6],
["a" => 7, "b" => 8, "c" => 9],
];
$column = "b";
$result = array_column($arr, NULL, $column);
print_r($result);
output:
Array
(
[2] => Array
(
[a] => 1
[b] => 2
[c] => 3
)
[5] => Array
(
[a] => 4
[b] => 5
[c] => 6
)
[8] => Array
(
[a] => 7
[b] => 8
[c] => 9
)
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…