BIG阳
这个Math_Combinatorics在PEAR存储库中,您想做什么就做什么:返回所有组合和排列的包,不重复、给定集和子集的大小。关联数组被保留。require_once 'Math/Combinatorics.php';$combinatorics = new Math_Combinatorics;$input = array(1, 2, 3, 4, 5, 6, 7);$output = $combinatorics->combinations($input, 5); // 5 is the subset size// 1,2,3,4,5// 1,2,3,4,6// 1,2,3,4,7// 1,2,3,5,6// 1,2,3,5,7// 1,2,3,6,7// 1,2,4,5,6// 1,2,4,5,7// 1,2,4,6,7// 1,2,5,6,7// 1,3,4,5,6// 1,3,4,5,7// 1,3,4,6,7// 1,3,5,6,7// 1,4,5,6,7// 2,3,4,5,6// 2,3,4,5,7// 2,3,4,6,7// 2,3,5,6,7// 2,4,5,6,7// 3,4,5,6,7