时间:2021-07-01 10:21:17 帮助过:32人阅读
$ar = array (
0 => array ( 'AdminName' => 'sysadm', 'MenuNo' => ''),
1 => array ( 'AdminName' => '00000', 'MenuNo' => '30,27,32' ),
2 => array ( 'AdminName' => '00000', 'MenuNo' => '25,26,27' ),
3 => Array ( 'AdminName' => '00001', 'MenuNo' => '30,27,32' ),
);
$res = array();
foreach($ar as $row) {
if(! isset($res[$row['AdminName']])) $res[$row['AdminName']] = $row;
else $res[$row['AdminName']]['MenuNo'] .= ',' . $row['MenuNo'];
}
print_r(array_values($res));
Array
(
[0] => Array
(
[AdminName] => sysadm
[MenuNo] =>
)
[1] => Array
(
[AdminName] => 00000
[MenuNo] => 30,27,32,25,26,27
)
[2] => Array
(
[AdminName] => 00001
[MenuNo] => 30,27,32
)
)