Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationFor loops

For loops

This for loop will assign $i with three and increment it by 1.

YASS
for($i = 3, $i < 10, 1)
  //Do something
end for
  

This for loop will assign $i to $j and increment $i by 2.

YASS
$j = 4
for($i = $j, $i < 10, 2)
  //Do something
end for
  

This for loop will not instantiate $i but will inform the loop that $i is the value to increment.

YASS
$i = 3
for($i, $i < 10, 1)
  //Do something
end for
  

As of version 1.4.2, for loops can be written in the exact syntax of a C-style for loop in that the $i++ can be used in place of the increment or decrement value. Placing a pre-decrement or pre-increment expression such as --$i will result in the value being changed before the for loop iterates.

YASS
for($i = 3; $i < 10; $i++)
  //Do something
end for
  

As with all loops, for loops may be terminated by end loop.

YASS
for($i = 3, $i < 10, 1)
  //Do something
end loop
  
Comments
Feedback 👍
Comments are sent via email to me.