如果还有其他与我的问题类似的问答,请让我知道解决方案使用递归函数:function permutations($elements) { if(count($elements)<2) return $elements; $newperms= array(); foreach($elements as $key=>$element) { $newelements= $elements; unset($newelements[$key]); $perms= permutations($newelements); foreach($perms as $perm) { $newperms[]= $element."-".$perm; } } return $newperms;}没有测试过,所以仍然可以为您工作;-)Don't know how to explain. But maybe example below will be make you understandable what my problem is.Example :I have an array with 3 elements.$elements = array( 'A', 'B', 'C' );The permutation will be 3 in 3. so the result are :A-B-C ; A-C-B ; B-A-C ; B-C-A ; C-A-B; C-B-AI don't want any permutation 2 in 3 or 1 in 3, just 3 in 3 as you can see in example. So if I have 4 elements in an array, the permutation is 4 in 4. and so on...(I think the number of permutations is 3! = 1*2*3 = 6 permutations, 4! = 1*2*3*4 = 24 permutations... that why I call Permutations of Factorial.)If there are other question and answer similar to my problem, please let me know 解决方案 Use a recursive function:function permutations($elements) { if(count($elements)<2) return $elements; $newperms= array(); foreach($elements as $key=>$element) { $newelements= $elements; unset($newelements[$key]); $perms= permutations($newelements); foreach($perms as $perm) { $newperms[]= $element."-".$perm; } } return $newperms;}Didn't test it, so there is still work for you ;-) 这篇关于PHP中阶乘的置换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 16:19