hi Guys. So I have a list of football matches, that are in certain tournaments, on certain dates - like this:
date
tournament
match
match
date
tournament
match
date
tournament
match
So you see the number of matches in a tournament can change and the number of tournaments on a date can change - sometimes no tournaments/matches at all.
I have managed to grab everything from the page, and I have stored it all in arrays. I can tell whether and object is an item or a date by the html formatting around it - so thats easy. I now have arrays of items and dates.
however I am now trying to reprint everything on another page in the correct order from my arrays:
the array that stores everything - regarless of whether it is a date/tournament/match is called $matches.Code:foreach($dayKeys as $a => $b) { echo "<table>"; //echo "<b>" .strip_tags($matches[$dayKeys[$a]])."</b><br>"; $c = $a; $d_check = 0;//checks whether day has been printed foreach($tournKeys as $c => $d) {//count number of tournaments if (($tournKeys[$c] > $dayKeys[$a]) && ($tournKeys[$c] < $dayKeys[$a + 1])) { $e = $c; $t_check = 0;//checks whether tournament has been printed foreach($gameKeys as $e => $f) {//count number of tournaments if (($gameKeys[$e] > $tournKeys[$c]) && ($gameKeys[$e] < $tournKeys[$c + 1])) {
Everything works perfectly, except for the last date - because no dates follow it
so therefore the condition:
fails because of $dayKeys[$a + 1] - there isnt a $dayKeys[$a + 1].Code:if (($tournKeys[$c] > $dayKeys[$a]) && ($tournKeys[$c] < $dayKeys[$a + 1]))
and the same goes for
however to print the list in the correct order again, I need to know whether the current match in the for loop comes before or after the next tournament heading, and also whether that comes before or after the next date heading.Code:if (($gameKeys[$e] > $tournKeys[$c]) && ($gameKeys[$e] < $tournKeys[$c + 1])) {
In other words, can I write this sort of thing:
$tournKeys[$c + 1]
another way so that if it is the last on the list, then it doesnt crash..?




Reply With Quote