Skip to main content

mbr_foreach

Usage

This shortcode performs a set of repetitive actions a fixed number of times, based on values passed to it, similar to a programming FOREACH loop.

Note

The internal variable placeholder <:foreach:> has an integer value incremented at each iteration.

Please consider the effect a large number of iterations could have on the performance of your site.

Parameters

ParametersDescription
setA set of comma separated (default) values passed to the shortcode, for each of which an iteration will be performed. The value set may include words or phrases, but may not include commas, unless a different separator is assigned.
Default: none.
Required: yes.
separatorThe separator to use in order to separate the values passed to the shortcode.
Default: , (comma)
Required: no.

Validity

This shortcode is evaluated for any type of visitor.

Conditional Branching

This shortcode does NOT support conditional branching with [ELSE_foreach].

Nesting

Shortcode nesting within is NOT supported.

Examples

All actions between the shortcode tags would be performed 5 times, once for each value in the "set". So the following will be displayed "Going through the loop; this time the value is 5.", "Going through the loop; this time the value is 12.", "Going through the loop; this time the value is 57.", "Going through the loop; this time the value is 31.", "Going through the loop; this time the value is 78.". The internal variable placeholder, <:foreach:> will be the current value from the set updated at each iteration:

[mbr_foreach set='5,12,57,31,78']
Going through the loop; this time the value is <:foreach:>.
[/mbr_foreach]

API

Note

There is no ActiveMember360 API function equivalent for this shortcode. Please use the PHP function foreach.