$items = array(
1 => [
"id" => 5
],
3 => [
"id" => 6
],
4 => [
"id" => 7
],
);
正确打印
var_dump(array_filter(array_combine(array_keys($items), array_column($items, 'id'))));
// 获取下标
$key = array_search(5, $items);// 1
array(3) {
[1]=>
int(5)
[3]=>
int(6)
[4]=>
int(7)
}
不保留key
var_dump(array_column($items,"id"));
array(3) {
[0]=>
int(5)
[1]=>
int(6)
[2]=>
int(7)
}