OUR SITES NetworkRADIUS FreeRADIUS

The foreach Statement

Syntax
foreach <attribute-reference> {
    [ statements ]
}

The foreach statement loops over a set of attributes as given by <attribute-reference>. The loop can be exited early by using the break keyword.

<attribute-reference>

The attribute reference which will will be looped over. The reference can be to one attribute, to an array, a child, or be a subset.

Inside of the foreach block, the attribute that is being looped over can be referenced as Foreach-Variable-0, through Foreach-Variable-9. The last digit is the depth of the loop, starting at "0". The loops can be nested up to eight (8) deep, though this is not recommended.

The attributes being looped over cannot be modified or deleted.

Example
foreach &Class {
    &reply += {
        Reply-Message = "Contains %{Foreach-Variable-0}"
    }
}
Example
foreach &TLV[*].Child-1 {
    &reply += {
        Reply-Message = "TLV contains %{Foreach-Variable-0}"
    }
}