PHParray_column重新构建⼆维数组$list = [
2021年开斋节是哪一天[
'id' => 1,
'name' => '刘德华',
'old' => 57,
'sex' => '男'
],
[
'id' => 2,
'name' => '梁朝伟',
'old' => 55,
'sex' => '男'
],
[
'id' => 3,
'name' => '刘嘉玲',
'old' => 59,
'sex' => '⼥'
根号下怎么打],
[
'id' => 4,
书名言
'name' => '俞飞鸿',
'old' => 59,
'sex' => '⼥'
叶玉卿图片
]
];
$f_list = array_column($list, 'name', 'old');//参数:数组新数组展⽰字段(仅⽀持1个字段) 新数组的key
print_r($f_list);die;
[
57 => '刘德华',
55 => '梁朝伟',
59 => '俞飞鸿',
]
;
//array_column第⼆个字段传null时,显⽰所有字段
$list = [
[
'id' => 1,
'name' => '刘德华',
'old' => 57,
'sex' => '男'
],
[
'id' => 2,
'name' => '梁朝伟',
'old' => 55,
'sex' => '男'
],
老师节日快乐贺卡图片[
谢霆锋失控发飙'id' => 3,
'name' => '刘嘉玲',
'old' => 59,
'sex' => '⼥'
],
[
'id' => 4,
'name' => '俞飞鸿',
'old' => 59,
'sex' => '⼥'
]
];
$f_list = array_column($list, null, 'old');//参数:数组新数组展⽰字段(仅⽀持1个字段) 新数组的key
print_r($f_list);die;
//输出结果
[
57 => [
'id' => 1,
'name' => '刘德华',
'old' => 57,
'sex' => '男'
],
55 => [
'id' => 2,
'name' => '梁朝伟',
'old' => 55,
'sex' => '男'
],
59 => [
'id' => 4,
'name' => '俞飞鸿',                'old' => 59,
'sex' => '⼥'
]
];