<?php
$a = [
[
‘id‘ => 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‘, )
原文:https://www.cnblogs.com/caibaotimes/p/14022427.html