Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.