Jump to content


Photo

calling previous loop


  • Please log in to reply
3 replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 13 June 2006 - 03:20 PM

Hard to explain, let's say you have to loops, loop a and loop b

can you make a script that runs loop a ( a while loop for example), then later does loop b (another while loop)

then if a certain clause at the end of loop b comes true, you can send it back to loop a...

in basic, it would be GOTO... PHP doesn't have that ability, does it?

#2 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 13 June 2006 - 03:24 PM

aha yes goto and :function is replace with
function foo () { } to define the function and foo(); to execute

$a = 3;

function foo ()
{
  while ($a > 1)
  {
   $a = $a - 1;
    echo "A is great";
  }
}

function mu ()
{
  while ($a < 1)
  {
   $a = $a + 1;
    echo "B is great";
  }
}

if ($a > 1) foo(); else mu();

if ($a == 1) echo "boring";

z..z..z..z..z..z..z..z..

#3 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 13 June 2006 - 03:33 PM

So, instead of going to the loop, you bring the loop to you...but no way to restart the entire script starting at that point...

[!--quoteo(post=383317:date=Jun 13 2006, 11:24 AM:name=joquius)--][div class=\'quotetop\']QUOTE(joquius @ Jun 13 2006, 11:24 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
aha yes goto and :function is replace with
function foo () { } to define the function and foo(); to execute

$a = 3;

function foo ()
{
  while ($a > 1)
  {
   $a = $a - 1;
    echo "A is great";
  }
}

function mu ()
{
  while ($a < 1)
  {
   $a = $a + 1;
    echo "B is great";
  }
}

if ($a > 1) foo(); else mu();

if ($a == 1) echo "boring";
[/quote]


#4 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 13 June 2006 - 03:47 PM

I've got a terrible migrane so ignore that junk, but what is it you need?

why do u need the beginning?
z..z..z..z..z..z..z..z..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users