Jump to content

jasmin0510

New Members
  • Posts

    3
  • Joined

  • Last visited

jasmin0510's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You really got me motivated, and I was in despair. I told my self - if this man thinks that I should try again than I will do it. I just reduced the number of iterations, make trace table and I had that moment of revelation😄 I didn't look up your hidden content in post, and I am glad that I didn't. Thank you very much. Have a wonderful holidays.🤗
  2. Thank you for this answer. Yeah, I understand that basic concept of continue and continue 2. But the results that I'm getting in this example are beyond my understanding and expectations. In first iteration $i = 0 and $d = 0, so the condition in if is TRUE and continue 2 is stopping further execution of code in this first iteration for both for loops, meaning that those two echo lines are not executed. So the iteration number 2 begins and now $i = 1 and $d = 1 and again condition in if is TRUE and continue is stopping that iteration. This is my understanding of things. What I don't understand is how I'm getting this: 0d,1i,0d,2i,1d,2i,0d,3i,1d,3i,2d,3i,0d,4i,1d,4i,2d,4i,3d,4i,0d,5i,1d,5i,2d,5i,3d,5i. I tried to resolve this with trace tables but that didn't help me. ☹️
  3. Hi guys and Marry Christmas to all of you who are celebrating! I'm traying to learn PHP on my own and I am stuck in traying to understand this concept of nested loops and using break/continue in them. So, can someone please explain to me how this code below is working and why I'm getting result that I don't expect. Code is: for($i = 0; $i < 6; $i++) { for($d = 0; $d < 4; $d++) { if($d == $i) { continue 2; } echo $d."d <br>"; echo $i."i <br>"; } } When I was writing this code I was expecting that result, because of continue 2, will be 4i and 5i. But instead of that I got this 0d,1i,0d,2i,1d,2i,0d,3i,1d,3i,2d,3i,0d,4i,1d,4i,2d,4i,3d,4i,0d,5i,1d,5i,2d,5i,3d,5i. I really want to how I got this result, I spent whole day traying to explain this to myself and failed miserably.
×
×
  • 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.