🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
​ ~~~php <?php /*二维数组去掉重复值*/ $arr=array( '0' => array ( 'wx_nickname' => '江淮智库', 'wx_name' => 'anhui-sky', 'url_times' => '0' ), '1' => array ( 'wx_nickname' => '安徽发布', 'wx_name' => 'anhuifabu', 'url_times' => '0' ), '2' => array ( 'wx_nickname' => '安徽发布', 'wx_name' => 'anhuifabu', 'url_times' => '0' ), '3' => array ( 'wx_nickname' => '江淮智库', 'wx_name' => 'anhuifabu', 'url_times' => '0' ), '4' => array ( 'wx_nickname' => '安徽发布', 'wx_name' => 'anhuifabu', 'url_times' => '0' ) ); function array_group_by($arr, $key) { $grouped = []; foreach ($arr as $value) { $grouped[$value[$key]][] = $value; } // Recursively build a nested grouping if more parameters are supplied // Each grouped array value is grouped according to the next sequential key if (func_num_args() > 2) { $args = func_get_args(); foreach ($grouped as $key => $value) { $parms = array_merge([$value], array_slice($args, 2, func_num_args())); $grouped[$key] = call_user_func_array('array_group_by', $parms); } } return $grouped; } var_dump(array_group_by($arr, 'wx_nickname')); ?> ~~~ ![](data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw== "点击并拖拽以移动") ​