Loops are one of the best ways to avoid repetition in your code. Instead of having to write similar lines of codes over and over, loops allow you to execute a block of code multiple times, each time using a different value (most often using arrays).

Instead of repeating yourself

::h3 "Users' ID List"
:: $users[0]
:: $users[1]
:: $users[2]
:: $users[3]
:: $users[4]
:: $users[5]
:: $users[6]
:: $users[7]
:: $users[8]
:: $users[9]

You can do the following using loops and get the exact same result.

::h3 "Users' ID List"
FOREACH($users AS $user) {
    :: $user

SunSed has 4 looping statements school FOR, school FOREACH, school WHILE, school DO...WHILE, each with its unique benefits optimal for different needs and requirements.

Copyright ©2013-2022 SunSed®. All rights reserved.