Oh yes poorface, I think we stopped at loops...
They're pretty easy to learn, I guess I can include them in my next tutorial, but here's an overview.
A loop can be either infinite, or specific, and the only way to stop a loop is to put 'break;' or 'return;' if it is infinite.
Lot's of ways to have loops on Graal.
I'm going to teach you the for(); loop today. Let me show you how it works correctly.
PHP Code:
function onCreated() {
for (i = 0; i < 6; i++) {
echo(i);
}
}
what this will echo is:
So how does this work? You have three arguments to have in a for() loop.
PHP Code:
for (i = 0; // This will be read once at the beginning
i < 5; // this will be checked everytime
i += 1 // or whatever you want to change every time the loop starts (WARNING, this does not take a semi colomn
) {
echo(i);
}
You can replace all of the above this way:
PHP Code:
function onCreated() {
i = 0;
if (i < 5) break;
echo(i);
i += 1; // or i++; whatever
if (i < 5) break;
echo(i);
i +=1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
if (i < 5) break;
echo(i);
i += 1;
// etc
}