(
[0] => Array
(
[ak] => 1
[fs] => 12
[tss] => sd第三方f
)
[1] => Array
(
[ak] => 2
[fs] => 12
[tss] => 是的发生
)
[2] => Array
(
[ak] => 3
[fs] => 22
[tss] => 好新玩
)
[3] => Array
(
[ak] => 4
[fs] => 22
[tss] => 八实得分
)
[4] => Array
(
[ak] => 6
[fs] => 22
[tss] => 八实得分
)
)
上面的数组是$abc
我下奶想形成新的数组把fs的值作为键名,然后把fs的值相同的,形成新的数组,。。
数组如下:
(
[12] => Array
(
[0] => Array
(
[ak] => 2
[tss] => 是的发生
)
[1] => Array
(
[ak] => 2
[tss] => 是的发生
)
)
[22] => Array
(
...............
)
)
$ar = array ( array ( 'ak' => '1', 'fs' => '12', 'tss' => 'sd第三方f', ), array ( 'ak' => '2', 'fs' => '12', 'tss' => '是的发生', ), array ( 'ak' => '3', 'fs' => '22', 'tss' => '好新玩', ), array ( 'ak' => '4', 'fs' => '22', 'tss' => '八实得分', ), array ( 'ak' => '6', 'fs' => '22', 'tss' => '八实得分', ),);$res = array();foreach($ar as $r) { $t = $r['fs']; unset($r['fs']); $res[$t][] = $r;}print_r($res);
Array( [12] => Array ( [0] => Array ( [ak] => 1 [tss] => sd第三方f ) [1] => Array ( [ak] => 2 [tss] => 是的发生 ) ) [22] => Array ( [0] => Array ( [ak] => 3 [tss] => 好新玩 ) [1] => Array ( [ak] => 4 [tss] => 八实得分 ) [2] => Array ( [ak] => 6 [tss] => 八实得分 ) ))
感受就是牛B。