I am building a bracket system (double elimination) and need to figure out how to create a loop that will return the proper matches according to seed.

For example, if a tournament has 8 teams the seeds would line up as follows:

Array(1,8,5,4,3,6,7,2);

Now I have temporarily built this into a static array:

PHP Code:
$this->seedData[8] = array(
                                
=> array(1,8,5,4,3,6,7,2),
                                
=> array(1,4,3,2),
                                
=> array(1,2),
                                
=> array(1)
                            ); 
Does anyone have any ideas how I can put a formula into a for loop that will generate this rather than having to build static arrays? The reasoning is due to having either 8, 16, 32 or 64 teams.

Thanks to anyone who is able to assist.