FOREACH Reference

The FOREACH loop allows you to iterate through items in a list.

Implicit variables

Example 1

The below example concatenates all the product codes together separating them with commas.

[FOREACH="BASKET"]
[IF="LOOP_INDEX"!="0"],[ENDIF="LOOP_INDEX"]###BRPRODCODE###
[ENDFOREACH="BASKET"]

Example 2

The below example lists all the store front product names in a 3 column table.

[FOREACH="STOREFRONT_PRODUCTS"]
	[IF="LOOP_MOD(3)"=="0"]<tr>[ENDIF="LOOP_MOD(3)"]
	###PRODUCT_NAME###
	[IF="LOOP_MOD(3)"=="2"]</tr>[ENDIF="LOOP_MOD(3)"]
	[IF="LOOP_LAST"]
		[IF="LOOP_MOD(3)"=="0"]<td>&nbsp;</td><td>&nbsp;</td></tr>[ENDIF="LOOP_MOD(3)"]
		[IF="LOOP_MOD(3)"=="1"]<td>&nbsp;</td></tr>[ENDIF="LOOP_MOD(3)"]
	[ENDIF="LOOP_LAST"]
[ENDFOREACH="STOREFRONT_PRODUCTS"]
SWREG offers a paypal alternative, affordable ecommerce, payment processing, ecommerce solution, and an online software store with the ability to sell shareware.