Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 360voice.com
 XML/APIs
 Need help with a PHP loop

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Insert Smilie
   
Message:

* HTML is OFF
* Forum Code is ON

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Koding Posted - Jul 04 2008 : 11:45:54 AM
OK, here's what I'm trying to do. I am trying to parse the blog-getentries XML that is displaying a user's info for all days in their current streak. The info I want is the the greatest gamerscore increase and the date during the streak.

I tried this first:
	for ($counter = 0; $counter < $profilexml->info->dayplayed; $counter++)
	{
		if ($daysplayedxml->blog->entry[$counter]->gsincrease > $biggestgsinc)
		{
			$biggestgsinc = $daysplayedxml->blog->entry[$counter]->gsincrease;
			$datebiggestgsinc = $daysplayedxml->blog->entry[$counter]->date;
		}
	}
$biggestgsinc has already been set to 0 and $profilexml->info->dayplayed is the number of days in the user's current streak.

Then I tried this:
	foreach ($daysplayedxml->blog->entry as $points)
	{	
		if ($points->gsincrease > $biggestgsinc)
		{
			$biggestgsinc = $points->gsincrease;
			$datebiggestgsinc = $points->date;
		}
	}
Neither way works and actually both give the same wrong answer. I'm sure it's something simple I'm overlooking so if anyone can give me a push in the right direction, I'd appreciate it.
2   L A T E S T    R E P L I E S    (Newest First)
Koding Posted - Jul 04 2008 : 12:06:04 PM
Thanks for the help TX E. That was the right function, but in the wrong place. This now works:
	for ($counter = 0; $counter < $profilexml->info->dayplayed; $counter++)
	{
		if (intval($daysplayedxml->blog->entry[$counter]->gsincrease) > $biggestgsinc)
		{
			$biggestgsinc = intval($daysplayedxml->blog->entry[$counter]->gsincrease);
			$datebiggestgsinc = $daysplayedxml->blog->entry[$counter]->date;
		}
	}
TX Eegras Posted - Jul 04 2008 : 11:47:53 AM
Try

for ($counter = 0; $counter <= intval($profilexml->info->dayplayed); $counter++)
	{
		if ($daysplayedxml->blog->entry[$counter]->gsincrease > $biggestgsinc)
		{
			$biggestgsinc = $daysplayedxml->blog->entry[$counter]->gsincrease;
			$datebiggestgsinc = $daysplayedxml->blog->entry[$counter]->date;
		}
	}

360voice Community © 2006 360voice.com Go To Top Of Page
Snitz Forums 2000