1 回答
TA贡献2003条经验 获得超2个赞
1 2 3 4 5 6 | <?php //ver.>4.4.0 $a=array('count'=>array(2,3,4,5), 'sku_id'=>array(1,2,3,5)); $o=array(); for($i=0,$len=count($a['sku_id']); $i<$len; $i++) $o[]=array('sku_id'=>$a['sku_id'][$i], 'count'=>$a['count'][$i]); var_dump($o); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | array (size=4) 0 => array (size=2) 'sku_id' => int 1 'count' => int 2 1 => array (size=2) 'sku_id' => int 2 'count' => int 3 2 => array (size=2) 'sku_id' => int 3 'count' => int 4 3 => array (size=2) 'sku_id' => int 5 'count' => int 5 |
通常是用简单合并就够了
1 2 | $b=array_combine($a['sku_id'],$a['count']); var_dump($b); |
1 2 3 4 5 | array (size=4) 1 => int 2 2 => int 3 3 => int 4 5 => int 5 |
- 1 回答
- 0 关注
- 1379 浏览
添加回答
举报