PHP 数组重组 把相同含有ID的放到一个新的数组了!
Array([0]=>Array([tid]=>26[tname]=>内衣[id]=>1)[1]=>Array([tid]=>25[tname]=>女装[id]=>1)[...
Array
(
[0] => Array
(
[tid] => 26
[tname] => 内衣
[id] => 1
)
[1] => Array
(
[tid] => 25
[tname] => 女装
[id] => 1
)
[2] => Array
(
[tid] => 27
[tname] => 男装
[id] => 2
)
[3] => Array
(
[tid] => 28
[tname] => 运动
[id] => 2
)
[4] => Array
(
[tid] => 29
[tname] => 户外
[id] => 2
)
[5] => Array
(
[tid] => 30
[tname] => 男鞋
[id] => 3
)
[6] => Array
(
[tid] => 31
[tname] => 女鞋
[id] => 3
)
[7] => Array
(
[tid] => 32
[tname] => 个人化妆
[id] => 4
)
) 展开
(
[0] => Array
(
[tid] => 26
[tname] => 内衣
[id] => 1
)
[1] => Array
(
[tid] => 25
[tname] => 女装
[id] => 1
)
[2] => Array
(
[tid] => 27
[tname] => 男装
[id] => 2
)
[3] => Array
(
[tid] => 28
[tname] => 运动
[id] => 2
)
[4] => Array
(
[tid] => 29
[tname] => 户外
[id] => 2
)
[5] => Array
(
[tid] => 30
[tname] => 男鞋
[id] => 3
)
[6] => Array
(
[tid] => 31
[tname] => 女鞋
[id] => 3
)
[7] => Array
(
[tid] => 32
[tname] => 个人化妆
[id] => 4
)
) 展开
2个回答
展开全部
$arr=array(
0=>搜饥array(
'tid'=>26,
'tname'=>'内衣',
'id'=>1
),
1=>array(
'tid'=>25,
'tname'=>'女装',
'id'=>1
),
2=>array(
'tid'=>27,
稿漏烂'tname'=>'男装',
'id'=>2
),
3=>array(
'tid'=>28,
'tname'=>'运动',
'id'=>2
),
4=>array(
'tid'=>29,
'tname'=>'户外',
'id'=>2
),
5=>array(
'tid'=>30,
'tname'=>'男鞋',
'id'=>3
),
6=>array(
'tid'=>31,
'tname'=>'女鞋',
'id'=>3
),
7=>array(
'tid'=>32,
'tname'键漏=>'个人化妆',
'id'=>4
),
);
$item=array();
foreach($arr as $k=>$v){
if(!isset($item[$v['id']])){
$item[$v['id']][]=$v;
}else{
$item[$v['id']][]=$v;
}
}
print_r($item);
2014-11-04
展开全部
$new =array();
foreach($arr as $key => $value){
$new[$value['吵州id'数碰歼薯冲]][]= $value;
}
foreach($arr as $key => $value){
$new[$value['吵州id'数碰歼薯冲]][]= $value;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询