Current location: Hot Scripts Forums » Programming Languages » PHP » Possible Combination


Possible Combination

Reply
  #1 (permalink)  
Old 11-30-04, 07:35 AM
dawit dawit is offline
New Member
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Possible Combination

Hello all,

I am developing a 8-ball pool website and i have a problem with fixtures. Teams are grouped in a league. There can be as many as 100 teams in a league. One team should play every other team. The script should display all the possible combination of teams. For example, if there are three teams A, B, and C, the script should display:

A --> B
A--->C

B--->A
B--->C

C-->A
C-->B

If you have any idea, how i can do this please, reply.
Reply With Quote
  #2 (permalink)  
Old 12-01-04, 03:54 AM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
something like this?
PHP Code:

 <?
 $teams 
= array('A''B''C');
 for (
$i=0;$i<count($teams);$i++) {
     for (
$n=0;$n<count($teams);$n++) {
         if (
$teams[$i] == $teams[$n]) {
             
next;
         } else {
             echo 
$teams[$i].' --> '.$teams[$n].'<br />';
         }
     }
 echo 
'<br />';
 }
 
?>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 05:17 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.