Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

7 number combiantions from an array

nrkamleshnrkamlesh Posts: 6Member
Please help me with this

:
:
: n = 20
: r = 5
:
: var combination = new Array(r);
:
: for(i=0; i r)
: index = r;
: while(combination[index-1]==n+index-r && index>0)
: index--;
: if(index==0)
: return false;
: combination[index-1]++;
: for(index++; index<=r; index++)
: combination[index-1] = combination[index-2]+1;
: }
: return true;
: }
: function showNext() {
: val = getNextCombination(n, r);
: if(!val) // No more combinations found
: return val;
:
: txt = "";
: for(i in combination)
: txt+=combination[i]+", ";
:
: // Show the combination somewhere
: window.status = txt;
:
:
: return val;
: }
: function init() {
: for(p=0; p<50000 && showNext(); p++); // Shows the first 50000 combinations or as many as there are
: }
: </script>
:
:
:
:


i want the same result in in php and my condition is i want to pass different king of numbers in . now this combinations goes sequence number like 1,2,3,4,5,6 and i want a combinations of different numbers from a array like i need a result of array(1,12,32,24,14) and r value is default 7 . can any one provide me a solution for this in php.

Thank in advance who ever helps me .

Comments

Sign In or Register to comment.