Jump to content

calling previous loop


AV1611

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?
Link to comment
https://forums.phpfreaks.com/topic/11880-calling-previous-loop/
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]
Link to comment
https://forums.phpfreaks.com/topic/11880-calling-previous-loop/#findComment-45070
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]
Link to comment
https://forums.phpfreaks.com/topic/11880-calling-previous-loop/#findComment-45074
Share on other sites

Archived

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

×
×
  • Create New...

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.