$arr=Array (
‘contract_type‘ => Array ( ‘0‘ => 0, ‘1‘ => 0, ‘2‘ => 0,‘3‘ => 0, ),
‘use_contract‘ => Array ( ‘0‘ => 7, ‘1‘ => 8, ‘2‘ => 9, ‘3‘ => 10, ),
‘use_name‘ => Array ( ‘0‘ => ‘合同人1‘, ‘1‘ => ‘合同人2‘, ‘2‘ => ‘合同人3‘, ‘3‘ => ‘合同人4‘, ),
‘contract_money‘ => Array ( ‘0‘ => ‘合同金1‘, ‘1‘ => ‘合同金2‘, ‘2‘ => ‘合同金3‘, ‘3‘ => ‘合同金4‘, ) );
$id_arr=$arr[‘use_contract‘];
unset($arr[‘use_contract‘]);
//重构二维数组。key 是id val 是更新字段
$new_arr=array();
foreach ($arr as $key=>$val){
foreach ($val as $k=>$v){
foreach ($id_arr as $id_k=>$id_v){
if($id_k==$k ){
$new[$id_v][$key]=$v;
}
}
}
}
var_dump($new);
时间: 2024-10-12 02:43:36