Jump to content

Archived

This topic is now archived and is closed to further replies.

AV1611

calling previous loop

Recommended Posts

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?

Share this post


Link to post
Share on other sites
aha yes goto and :function is replace with
function foo () { } to define the function and foo(); to execute

[code]
$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";
[/code]

Share this post


Link to post
Share on other sites
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) [snapback]383317[/snapback][/div][div class=\'quotemain\'][!--quotec--]
aha yes goto and :function is replace with
function foo () { } to define the function and foo(); to execute

[code]
$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";
[/code]
[/quote]

Share this post


Link to post
Share on other sites
I've got a terrible migrane so ignore that junk, but what is it you need?

why do u need the beginning?

Share this post


Link to post
Share on other sites

×

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.