我的方法是这样的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <code><?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 );
</code>
|
登入後複製
登入後複製
回复内容:
我的方法是这样的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <code><?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 );
</code>
|
登入後複製
登入後複製
http://php.net/manual/zh/function.array-column.php