Alicia Posted January 26, 2010 Share Posted January 26, 2010 Hi I would like ask is how can I actually generate the result as below : From 4 digits to 3 digits permuted numbers e.g : 1234 (user enter this) Generated numbers : 123 124 134 234 ... What we want is use the number posted by user, and we will use the number to arrange to 3 digit numbers in any possible ways as above. Repeated permuted numbers will only display once. Please advise. Thank you. Link to comment https://forums.phpfreaks.com/topic/189889-3-chars-with-permu/ Share on other sites More sharing options...
teamatomic Posted January 26, 2010 Share Posted January 26, 2010 When I did up a lottery script this is one of the sites I bookmarked http://www.php.happycodings.com/Algorithms/code21.html HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189889-3-chars-with-permu/#findComment-1002080 Share on other sites More sharing options...
Alicia Posted January 27, 2010 Author Share Posted January 27, 2010 thanks for the reference. Actually what I need is from 4 numbers then generated the numbers in 3 without repetition of the same numbers. From the reference given, I don't think it is possible to do that right? please advise. Link to comment https://forums.phpfreaks.com/topic/189889-3-chars-with-permu/#findComment-1002172 Share on other sites More sharing options...
teamatomic Posted January 27, 2010 Share Posted January 27, 2010 Where you call the function you have: function($this_is_the_number_string, X_is the length of the integer returned). If you modify the output pushes just the numbers into the array you can then do an array_unique on it and then whatever you want with the array. At the start of the script $str='1234'; at the bottom $Array=permutations("$str",3); Try it, you'll like it. HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/189889-3-chars-with-permu/#findComment-1002191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.