Hi
I have an xml file which i get data from using the simplexml_load_file function
I then grab values and store them in variables

now the thing is that the amount of games displayed will be different

I need to grab the values from them with a while loop or something

If it where mysql i would go about using the following method

while($r=mysql_fetch_array($query))
{
$idorder=$r["idorder"];
}

How could I go about using the same type of method in this scenario?

Bear in mind my skillz are limited
Portion of xml file :

[RecentGames] => SimpleXMLElement Object
        (
            [XboxUserGameInfo] => Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%60m%2fl%3b%7c%03
                                    [Name] => Call of Duty: WaW
                                    [TotalAchievements] => 56
                                    [TotalGamerScore] => 1250
                                    [Image32Url] => http://tiles.xbox.com/tiles/7M/zf/02dsb2JgbA9ECgQJGgYfVl4gL2ljb24vMC84MDAwIAABAAAAAPzwzPM=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/g2/Lr/1Gdsb2JhbC9ECgQJGgYfVl4gL2ljb24vMC84MDAwAAAAAAAAAPvEYpw=.jpg
                                )

                            [LastPlayed] => 2009-07-21T12:29:14+00:00
                            [Achievements] => 13
                            [GamerScore] => 200
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%60m%2fl%3b%7c%03&compareTo=XENNON187
                        )

                    [1] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%60m%2fl4%07%02
                                    [Name] => Call of Duty 4
                                    [TotalAchievements] => 37
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/3g/9G/0Wdsb2JgbA9ECgQJGgYfWSpVL2ljb24vMC84MDAwIAABAAAAAP5pD8E=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/sa/Fy/1mdsb2JhbC9ECgQJGgYfWSpVL2ljb24vMC84MDAwAAAAAAAAAPldoa4=.jpg
                                )

                            [LastPlayed] => 2009-07-19T17:32:03+00:00
                            [Achievements] => 28
                            [GamerScore] => 610
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%60m%2fl4%07%02&compareTo=XENNON187
                        )

                    [2] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bei*h%3eys
                                    [Name] => Rainbow Six® Vegas 2
                                    [TotalAchievements] => 47
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/tl/JM/0mdsb2JgbA9ECgUNGgMfVl9UL2ljb24vMC84MDAwIAABAAAAAP1jUqk=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/2f/x4/1Wdsb2JhbC9ECgUNGgMfVl9UL2ljb24vMC84MDAwAAAAAAAAAPpX-MY=.jpg
                                )

                            [LastPlayed] => 2009-07-12T09:58:56+00:00
                            [Achievements] => 8
                            [GamerScore] => 145
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bei*h%3eys&compareTo=XENNON187
                        )

                    [3] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%15%18*iArp
                                    [Name] => Forza Motorsport 2
                                    [TotalAchievements] => 44
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/EW/XG/1Wdsb2JgbA9ECgR8GgMfWSoiL2ljb24vMC84MDAwIAABAAAAAPrpZQ4=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/fs/vy/0mdsb2JhbC9ECgR8GgMfWSoiL2ljb24vMC84MDAwAAAAAAAAAP3dy2E=.jpg
                                )

                            [LastPlayed] => 1753-01-01T00:00:00+00:00
                            [Achievements] => 3
                            [GamerScore] => 15
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%15%18*iArp&compareTo=XENNON187
                        )

                    [4] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bei*h%3exu
                                    [Name] => Far Cry® 2
                                    [TotalAchievements] => 48
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/2Z/tA/0Wdsb2JgbA9ECgUNGgMfVl5TL2ljb24vMC84MDAwIAABAAAAAP5vm8Y=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/tj/V0/1mdsb2JhbC9ECgUNGgMfVl5TL2ljb24vMC84MDAwAAAAAAAAAPlbNak=.jpg
                                )

                            [LastPlayed] => 2009-07-10T23:45:37+00:00
                            [Achievements] => 11
                            [GamerScore] => 170
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bei*h%3exu&compareTo=XENNON187
                        )

                    [5] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bei*h%3ex%06
                                    [Name] => Call of Juarez: BiB
                                    [TotalAchievements] => 47
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/yn/7y/02dsb2JgbA9ECgUNGgMfVl4gL2ljb24vMC84MDAwIAABAAAAAPzdftU=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/pd/DG/1Gdsb2JhbC9ECgUNGgMfVl4gL2ljb24vMC84MDAwAAAAAAAAAPvp0Lo=.jpg
                                )

                            [LastPlayed] => 2009-07-10T22:29:44+00:00
                            [Achievements] => 0
                            [GamerScore] => 0
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bei*h%3ex%06&compareTo=XENNON187
                        )

                    [6] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3adh)k0%03q
                                    [Name] => Battlefield 2: MC
                                    [TotalAchievements] => 46
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/PF/t6/02dsb2JgbA9ECgQNGwEfWSshL2ljb24vMC84MDAwIAABAAAAAPxVWyM=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/U-/VO/1Gdsb2JhbC9ECgQNGwEfWSshL2ljb24vMC84MDAwAAAAAAAAAPth9Uw=.jpg
                                )

                            [LastPlayed] => 2009-07-10T19:18:20+00:00
                            [Achievements] => 0
                            [GamerScore] => 0
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3adh)k0%03q&compareTo=XENNON187
                        )

                    [7] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3ahd%2fm%3c%0d%03
                                    [Name] => Ghostbusters
                                    [TotalAchievements] => 50
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/dN/DC/1Gdsb2JgbA9ECgQBGwcfWSlXL2ljb24vMC84MDAwIAABAAAAAPvt0Gs=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/G3/72/02dsb2JhbC9ECgQBGwcfWSlXL2ljb24vMC84MDAwAAAAAAAAAPzZfgQ=.jpg
                                )

                            [LastPlayed] => 2009-07-10T19:11:31+00:00
                            [Achievements] => 3
                            [GamerScore] => 20
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3ahd%2fm%3c%0d%03&compareTo=XENNON187
                        )

                    [8] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bdh(j%3fx%02
                                    [Name] => Red Faction: Guerrilla
                                    [TotalAchievements] => 50
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/MG/uZ/0Gdsb2JgbA9ECgUMGgEfVl8nL2ljb24vMC84MDAwIAABAAAAAP+2ay8=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/X8/Wt/12dsb2JhbC9ECgUMGgEfVl8nL2ljb24vMC84MDAwAAAAAAAAAPiCxUA=.jpg
                                )

                            [LastPlayed] => 2009-07-07T18:52:08+00:00
                            [Achievements] => 3
                            [GamerScore] => 20
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bdh(j%3fx%02&compareTo=XENNON187
                        )

                    [9] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3adh)k0%01%08
                                    [Name] => BF: Bad Company
                                    [TotalAchievements] => 50
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/ga/6a/0Gdsb2JgbA9ECgQNGwEfWSlaL2ljb24vMC84MDAwIAABAAAAAP+1rp4=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/7g/Cu/12dsb2JhbC9ECgQNGwEfWSlaL2ljb24vMC84MDAwAAAAAAAAAPiBAPE=.jpg
                                )

                            [LastPlayed] => 2009-07-07T17:37:25+00:00
                            [Achievements] => 1
                            [GamerScore] => 25
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3adh)k0%01%08&compareTo=XENNON187
                        )

                    [10] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3adh)k%3fqz
                                    [Name] => Fight Night Round 4
                                    [TotalAchievements] => 33
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/qt/vI/0Wdsb2JgbA9ECgQNGwEfVlZXL2ljb24vMC84MDAwIAABAAAAAP7n27U=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/xX/X8/1mdsb2JhbC9ECgQNGwEfVlZXL2ljb24vMC84MDAwAAAAAAAAAPnTddo=.jpg
                                )

                            [LastPlayed] => 2009-07-07T16:40:02+00:00
                            [Achievements] => 0
                            [GamerScore] => 0
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3adh)k%3fqz&compareTo=XENNON187
                        )

                    [11] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3abn%5c%1e9%7e%0b
                                    [Name] => Overlord II
                                    [TotalAchievements] => 49
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/Wr/af/0Wdsb2JgbA9ECgQLG3QfVl9aL2ljb24vMC84MDAwIAABAAAAAP6wtkU=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/NR/ir/1mdsb2JhbC9ECgQLG3QfVl9aL2ljb24vMC84MDAwAAAAAAAAAPmEGCo=.jpg
                                )

                            [LastPlayed] => 2009-07-06T19:40:45+00:00
                            [Achievements] => 0
                            [GamerScore] => 0
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3abn%5c%1e9%7e%0b&compareTo=XENNON187
                        )

                    [12] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3adh)k%3f%7bt
                                    [Name] => Left 4 Dead
                                    [TotalAchievements] => 50
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/4H/0l/0Wdsb2JgbA9ECgQNGwEfVlxTL2ljb24vMC84MDAwIAABAAAAAP4Kff8=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/j9/MR/1mdsb2JhbC9ECgQNGwEfVlxTL2ljb24vMC84MDAwAAAAAAAAAPk+05A=.jpg
                                )

                            [LastPlayed] => 2009-06-26T16:06:52+00:00
                            [Achievements] => 1
                            [GamerScore] => 20
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3adh)k%3f%7bt&compareTo=XENNON187
                        )

                    [13] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bdh-o0%01%07
                                    [Name] => GTA IV
                                    [TotalAchievements] => 55
                                    [TotalGamerScore] => 1250
                                    [Image32Url] => http://tiles.xbox.com/tiles/8x/Us/1Wdsb2JgbA9ECgUMGgQfWSlRL2ljb24vMC84MDAwIAABAAAAAPoDFew=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/nL/sY/0mdsb2JhbC9ECgUMGgQfWSlRL2ljb24vMC84MDAwAAAAAAAAAP03u4M=.jpg
                                )

                            [LastPlayed] => 2009-06-26T13:16:09+00:00
                            [Achievements] => 1
                            [GamerScore] => 5
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bdh-o0%01%07&compareTo=XENNON187
                        )

                    [14] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3a%13%1f%5c%1eGtw
                                    [Name] => Sacred 2 Fallen Angel
                                    [TotalAchievements] => 48
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/Ti/0A/0mdsb2JgbA9ECgR6G3QfWStSL2ljb24vMC84MDAwIAABAAAAAP0vLVE=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/IY/M0/1Wdsb2JhbC9ECgR6G3QfWStSL2ljb24vMC84MDAwAAAAAAAAAPobgz4=.jpg
                                )

                            [LastPlayed] => 2009-06-26T10:38:51+00:00
                            [Achievements] => 0
                            [GamerScore] => 0
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3a%13%1f%5c%1eGtw&compareTo=XENNON187
                        )

                    [15] => SimpleXMLElement Object
                        (
                            [Game] => SimpleXMLElement Object
                                (
                                    [GameID] => %09%5d%3bei*h1%02%07
                                    [Name] => Splinter Cell D.A.
                                    [TotalAchievements] => 38
                                    [TotalGamerScore] => 1000
                                    [Image32Url] => http://tiles.xbox.com/tiles/5-/Ys/1Wdsb2JgbA9ECgUNGgMfWStUL2ljb24vMC84MDAwIAABAAAAAPoD9vg=.jpg
                                    [Image64Url] => http://tiles.xbox.com/tiles/iF/gY/0mdsb2JhbC9ECgUNGgMfWStUL2ljb24vMC84MDAwAAAAAAAAAP03WJc=.jpg
                                )

                            [LastPlayed] => 2009-06-26T08:22:29+00:00
                            [Achievements] => 1
                            [GamerScore] => 10
                            [DetailsURL] => http://live.xbox.com/en-US/profile/Achievements/ViewAchievementDetails.aspx?tid=%09%5d%3bei*h1%02%07&compareTo=XENNON187
                        )

                )

not to sound funny or anything i was there

I understand how to get an exact value from an array by index

but dunno how to iterate through them

I can do it with a mysql_fetch_array

Am I missing something ?

Evidently you missed the entire page about foreach then.

Evidently you missed the entire page about foreach then.

its not that I just dont seem to understand how to apply it to this instance

OK, then post your code and I can give you a hand otherwise I'm just guessing at what it looks like.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.