PHPCodemania Posted July 27, 2020 Share Posted July 27, 2020 Hi there, I'm confused about why when you place the 'if' after the action in the continue command, you get such a strange outcome. Please see below: Why does this skip the outputs of '2', '6' and '8'? Thank you! Link to comment Share on other sites More sharing options...
Funce Posted July 28, 2020 Share Posted July 28, 2020 The 'continue' keyword in this case, is actually referring to the while loop its inside. The 'continue' indicates that you finish the current loop of the while, and continue onto the next. The reason why the numbers are skipped, is because the loop is 'continued' before the output is sent. Link to comment Share on other sites More sharing options...
PHPCodemania Posted July 28, 2020 Author Share Posted July 28, 2020 Ohh I totally get it now - I think I failed to see the "$x++" action was at the end of the process and was confused as to why things were working the way they did. Thanks very much for your reply!! Link to comment Share on other sites More sharing options...
Funce Posted July 28, 2020 Share Posted July 28, 2020 17 hours ago, PHPCodemania said: Ohh I totally get it now - I think I failed to see the "$x++" action was at the end of the process and was confused as to why things were working the way they did. Thanks very much for your reply!! Probably more closer to the answer, is that there's two lots of $x++ in the loop in the second example. So you're incrementing by two each time. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now