时间:2021-07-01 10:21:17 帮助过:4人阅读
33, // 这里的键名不固定
'name' => 'aaa',
],
[
'id' => 22,
'name' => 'bbb'
]
];
$dat = [];
foreach ($a as $b) {
list($k, $v) = array_values($b);
$dat[$k] = $v;
}
var_export($dat); //
输出:array ( 33 => 'aaa', 22 => 'bbb', )
我的方法是这样的:
33, // 这里的键名不固定
'name' => 'aaa',
],
[
'id' => 22,
'name' => 'bbb'
]
];
$dat = [];
foreach ($a as $b) {
list($k, $v) = array_values($b);
$dat[$k] = $v;
}
var_export($dat); //
输出:array ( 33 => 'aaa', 22 => 'bbb', )
http://php.com/manual/zh/function.array-column.php