Jump to content

willsko87

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

willsko87's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry to dbl post but it wouldn't let me edit it. To the last poster, how would I place both those outputted names into an array so I can call them separately?
  2. Ok that works. It ends up outputting the first 'name' from each. Thanks for that. Ultimately I would like to output the name of the players (attribute "name") in order of how many goals they have scored (attribute "g"). Any ideas how I would go about doing this?
  3. That doesn't do anything :-\ Still no output
  4. Hi, I am trying to pull some information from an xml file but I am having trouble trying to access some values. There are two <stats> sections but I can only seem to access the second one. Here is the XML file: <game_live> <stats team="h"> <player name="A Player" shortname="a" num="10" id="250365" pos="INT" k="8" h="10" m="7" t="4" ho="0" ff="2" fa="1" g="0" b="0" in50="2" rankingpoints="87" fantasypoints="80"/> </stats> <stats team="a"> <player name="B Player" shortname="b" num="44" id="220009" pos="CHB" k="14" h="12" m="6" t="1" ho="0" ff="0" fa="1" g="0" b="0" in50="1" rankingpoints="92" fantasypoints="85"/> </stats> I am trying to get the players name under the first stats section. This would be 'A Player' but I cannot work out how to get it. Below is the code I've used . <?php $xmlFileData = file_get_contents("match-10250605.xml"); $xmlData = new SimpleXMLElement($xmlFileData); foreach($xmlData->stats[0] as $stats1) { $name = $stats1->player[0]["name"]; } echo "Name: ".$name; ?> For some reason there is no output. If I put in just 'stats' instead of 'stats[0]' then it goes straight the second stats section and outputs that players name 'B Player'. What am I doing wrong?
×
×
  • 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.