$array = array_values($array);//二维数组,其中的元素就是需要均匀分布的数组$temp_array = [];foreach ($array as $item){$temp_array[count($item)][] = $item;}ksort($temp_array);$array = [];//按照子元素的数组长度,从小到大重新排序,重组数组foreach ($temp_array as $item){foreach ($item as $value){$array[] = $value;}}$order = [];while ($enterprises_staffs = array_shift($array)) {$temp = array_column($enterprises_staffs, 'id');if (empty($order)) {$order = $temp;} else {$score = round(count($order) / count($temp), 2);$index = count($order) / 2;$left = ceil(count($temp) / 2);$right = count($temp) - $left;$left_nums = $right_nums = 0;$key = 1;foreach ($temp as $id) {if ($left_nums < $left) {$l_index = $index - $key * $score;while (isset($order["{$l_index}"])) {$l_index -= 0.1;}$order["{$l_index}"] = $id;++$left_nums;++$key;if ($left_nums == $left) {$key = 0;}} elseif ($right_nums < $right) {$r_index = $index + $key * $score;while (isset($order["{$r_index}"])) {$r_index += 0.1;}$order["{$r_index}"] = $id;++$right_nums;++$key;if ($right_nums == $right) {$key = 0;}}}ksort($order);$order = array_values($order);}}var_dump($order);