freelance84 Posted May 12, 2010 Share Posted May 12, 2010 Ok I have the following: Road Possible Options 1 1, 2, 3 2 1, 2, 3 3 1, 2, 3 The user must use road 1, then road 2 then road 3. I want to be able to tell php to show all the possible combinations of the above. i.e: 111, 112, 113, 211, 212, 213, 221, 222.... etc etc. If road = $road and possible options = $pso Any ideas? I'm stumped, never done this before, can do it in my head obviously but no idea how to tell a computer how to do it. Thanks in advance for any help Link to comment https://forums.phpfreaks.com/topic/201470-pulling-out-all-poss-combinations/ Share on other sites More sharing options...
freelance84 Posted May 12, 2010 Author Share Posted May 12, 2010 I can't believe it but i think i've done it: $count1 = count array $pso1 $count2 = count array $pso2 $count3 = count array $pso3 for($a = 1 ; $a < $count1 ; ++$a) { for($b = 1 ; $b <$count2;++$b) { for($c = 1 ; $c < $count3 ; ++$c) { echo $pso[$a].$pso[$b].$pso[$c] "<br />"; } } } Link to comment https://forums.phpfreaks.com/topic/201470-pulling-out-all-poss-combinations/#findComment-1057009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.