Thread: Array Help
View Single Post
Old 08-25-2009, 04:28 PM   #1 (permalink)
Hightower
The Acquainted
 
Hightower's Avatar
 
Join Date: May 2009
Location: Durham, UK
Posts: 134
Thanks: 9
Hightower is on a distinguished road
Default Array Help

I have another thread ongoing about sorting an array, but I have a couple of other things I would like to achieve if anybody can help me:

1) Lets say I have an array of 10 items. I only want to show 5 items on the screen. These 5 items will vary, so it might be items 1-5, or items 2-6 or items 4-8 etc. To make it easier to understand, think of a league table. Now I only want to show the two records above, and two records below based on my team of choice:

Pos 3: Team 1
Pos 4: Team 2
Pos 5: My Team
Pos 6: Team 4
Pos 7: Team 5

(Notice how positions 1-2 and 8-10 are not shown)

2) I need to echo the name of each key for the positions in the table. So lets say my array is:

PHP Code:
array ([1] => Team 1, [2] => Team 2, [3] => Team 3 //and so on 
And I start my table snippet at position two. By echoing the key I show the position of that team - I just don't know how to do it.

Sorry if it's a bit of a mouth full, but any help is greatly apprecfiated!

Many thanks,
__________________
Hightower's Softpolio
Send a message via MSN to Hightower
Hightower is offline  
Reply With Quote