Page 1 of 1
Scrolling array
Posted: Tue Oct 04, 2005 8:40 am
by Crew
Code: Select all
function WeekGen($week,$array_size,$array,$index,$ud)
{
$array_count = $index+$week;
if($array_count>$array_size) {
$array_count = $array_count - $array_size;
}
$weekgen = $array[$array_count];
return $weekgen;
}
Hi
Using the above code I have an array that loops through itself like:
Code: Select all
Week 1
1
2
3
4
Week 2
4
1
2
3
Week 3
3
4
1
2
Now what I'm trying to do is get it so the weeks are as follows
Code: Select all
Week 1
1 4
2 3
Week 2
4 3
1 2
Week 3
3 2
4 1
And as simple as this sounds I really am struggling to get it to display in anything readable. Its frustrating
So does anyone have any hints or tips? And yes its a football league creator I'm making for a local league.
Posted: Tue Oct 04, 2005 9:07 am
by Jenk
Could you be a little more specific in terms of what the functions variables are used for?
Such as what is $index, $array_size etc.
Also, when you display the data, I know you have displayed the layout, but how would the layout be presented? Like that or in HTML Tables or divs/spans?
Posted: Tue Oct 04, 2005 9:47 am
by pickle
I imagine you're output code looks similar to this:
Code: Select all
foreach($weeks as $curr_week)
{
foreach($curr_week as $day)
{
echo $day."<br />";
}
echo "<br />";
}
If you want to put columns in, change it like this:
Code: Select all
foreach($weeks as $curr_week)
{
$column = 1;
foreach($curr_week as $day)
{
echo $day;
if($column%2 == 0)
{
echo "<br />";
}
++$column;
}
echo "<br />";
}
That will dump a <br /> every 2 items.