Jump to content

denhamd2

Members
  • Posts

    81
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

denhamd2's Achievements

Member

Member (2/5)

0

Reputation

  1. Awesome! Works perfectly! Thanks so so much!
  2. Thanks for this advice. Unfortunately I do not have access to a database, so I need to use just XML. The level I need them sorted is instead of within each league, it should be within each sport. How hard would it be to do this?
  3. So by re-structuring the array, do you mean having the top level be the date? Like so?... Array ( [201301041400] => Array { [Town Rovers vs Chanel] => Array ( [0] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link1.html ) [1] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link2.html ) [2] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link3c.html ) [3] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link4.html ) ) ) }
  4. Thanks again for your help with this. It now filters by date but only within the scope of each tournament. Is it possible to do an absolute filter by date with all tournaments?
  5. Many thanks that's brilliant I just realised my list of events is not outputting in order of nearest date and time first... would you have any idea how to do this please? I promise this is the last question - thanks so much again!
  6. Excellent, this works a charm - thanks so much! One last thing ... I'm trying to output the time and date from the XML node "thetime" in the format: Blue League - Blue United vs FC Turf - 29th December 2013, 16:00 Any idea how I'd do this? Thanks again
  7. This is perfect, thanks so much again. In terms of outputting it in HTML, I'm trying to output it like below: Football Red League - Town Rovers vs Chanel Link 1: 300: en: link1.html Link 2: 300: en: link2.html Link 3: 300: en: link3.html Link 4: 300: en: link4.html Blue League - Blue United vs FC Turf Link 5: 200: en: link5.html Link 6: 300: de: link6.html Link 7: 500: en: link7.html Link 8: 300: en: link8.html I just can't get my head around how to use the perfectly formatted array you gave me to do this. I just keep getting errors. Any last help you could offer would be hugely appreciated!
  8. Thats brilliant thanks! The only things that are missing are the sportname, tournamentname and thetime - any idea how to include those in the array? Thanks again for your help
  9. Hi, In the XML I posted, you can see them as attributes: <link lang="en" kbps="300" channelname="Link 1"> Any idea how I'd pull them out to replace your hard coded values?
  10. Thanks for your reply - I've updated my code. For the attributes in the array you pasted, will the channel name output as "Link 3" or literally "CHANNEL"? Also, I'm not able to output my HTML for some reason. Here is my code: foreach ($acopy AS $thematches) { $singlematchname = strtolower($thematches->matchname); // FORMAT $singlematchlinks = ''; // LOOP THROUGH ALL LINKS foreach ($thematches->linkset->link AS $link) { $singlematchlinks .= '<div class="matchrow"><div class="channelname">'.$link["channelname"].'</div><div class="language">'.$link["lang"].'</div><div class="kbps">'.$link["kbps"].'</div><div class="link"><a href="'.$link.'" target="_blank">Watch</a></div><div class="clearb"></div></div>'; } echo '<h5>'.$singlematchname.'</h5>'.$singlematchlinks; } This gives the error: Warning: Invalid argument supplied for foreach() in /home/freefoot/public_html/newsite/read_test2.php on line 55 Line 55 starts with: foreach ($thematches->linkset->link AS $link) Any idea what I might be doing wrong?
  11. Hi, I have an XML files of sports events (see below). Some of the events have the same match name, so I've put everything into an array and then tried to match them using matchname as a key. The XML looks like this: <match><sportname>Football</sportname><tournamentname>Red League</tournamentname><thetime>201311021245</thetime><matchname dateandtime="1383396300">Town Rovers vs Chanel</matchname><linkset><link lang="en" kbps="300" channelname="Link 1">link1.html</link><link lang="en" kbps="350" channelname="Link 2">link2.html</link></linkset></match> <match><sportname>Football</sportname><tournamentname>Red League</tournamentname><thetime>201311021245</thetime><matchname dateandtime="1383396300">Town Rovers vs Chanel</matchname><linkset><link lang="en" kbps="320" channelname="Link 3">link3c.html</link><link lang="en" kbps="320" channelname="Link 3">link4.html</link></linkset></match> Here's my PHP code (I'm pulling in the XML file using SimpleXML)... $xml = simplexml_load_file('test3.xml'); $aCopy = array(); foreach ($xml->match AS $match) { if (!isset($aCopy[(string)$match->matchname])) { $aCopy[(string)$match->matchname] = $match; } else { foreach ($match->linkset->link AS $link) { $aCopy[(string)$match->matchname]->linkset->addChild('link', $link); } } } The code above seems to have gotten me 80% of the way in that they are matching ok and the links output ok. But the weird thing is the attributes on the 2nd instance of the match aren't outptting... Link 1 en 300 link1.html Link 2 en 350 link2.html [blank] [blank] [blank] link3.html [blank] [blank] [blank] link4.hmtl (Where [blank] is supposed to be the channelname, lang and kbps outputted attributes) Any suggestions on what I might be doing wrong here? Thanks in advance for any help you can offer.
  12. HI, How would you change the array structure? Also this needs to come from an XML file rather than a DB.
  13. I have a muli-dimensional array (see below). I'm trying to use PHP to group matching events. Basically any matchname that is a duplicate (eg. Reds vs Whites) to group them together and group their linksets... Array ( [matches] => Array ( [match] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021600 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link1.html ) [0] => Array ( [sportname] => Football [tournamentname] => Prince League [thetime] => 201308021130 [matchname] => Blues vs Yellows [linkset] => Array ( [link] => link2.html ) ) [1] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021000 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link3.html ) ) ) ) ) I am trying to end up with Football: Reds vs Whites (201308021600) - Crown League Links: link1.html, link3.html Football: Blues vs Yellows (201308021130) - Prince League Links: link2.html I've been looking at the PHP manual but tearing my hair out trying to get it to output the above. Any ideas would be most welcome. Thanks
  14. Hi, I'm using Simple XML to read from an XML file. I've done a loop for each event. It gives me all the events back in the order of the XML file. However, instead I am trying to sort events by date. Any idea how I could do this? Please see my code below. FYI, the date and time is in UTC timestamp format (eg. 1377361800) Thanks in advance for your help. $newresult = $result->xpath("//match/matchname[.='$uniqueteam']/.."); foreach ($newresult as $newmatchlist) { $newmatch = trim($newmatchlist->{'matchname'}[0]); $sport = $newmatchlist->{'sportname'}[0]; $tournament = $newmatchlist->{'tournamentname'}[0]; $time=$newmatchlist->{'matchname'}[0]['dateandtime']; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.