problems with a loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

problems with a loop

Post by anthony88guy »

I’m trying to make a small program for a text based game. When you enter in a persons ID it will scan the page for his/her "commander" and then it should open that commanders link and do the same intill there is no commander.

Here is my current code:

Code: Select all

edited...
My problem occurs when you enter a ID with a commander the program will get the commanders id but it wont put it back into the preg_match(). How would I go about doing this? My problem is resetting the variable $id.

Once I this working I will develop it better.

Thanks A lot.

-anthony
Last edited by anthony88guy on Sun Nov 20, 2005 9:31 pm, edited 1 time in total.
yum-jelly
Forum Commoner
Posts: 98
Joined: Sat Oct 29, 2005 9:16 pm

Post by yum-jelly »

If your just wanting to loop the ID returned from the preg_ then just assign $match[1] to $id! In other words reverse what you have now...

Code: Select all

if($found != 0)
	{
		echo "id: " . $match[1];

		// reverse this....  $match[1] = $id;

		// like so...

		$id = $match[1];

	}
	else
	{
		$loop = 0;
	}

yj
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

thxs, i feel pretty stupid right now.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

anthony88guy wrote:thxs, i feel pretty stupid right now.
Don't worry about it - sometimes it just takes a second pair of eyes looking at a problem :)

Mac
Post Reply