There are two field types which can generate an array. These are the multi-select list and the database quiry (multi-select) field type.
First we check IF there is an array output for the field you are using:
Next we render the values in a 'repeatable' output using the foreach command: Note, the key ($k) corresponds to the multi-select list value and the item ($i) to the multi-select list text.
Example: The code below will generate a comma seperated list (with full stop at the end) for selected value from a multi-select list whereby the values correspond with the Joomla article IDs and JCE mediabox plugin is used to open them in a popup. The link text is the text shown in the multi-select list.
Condition for value in array
It is possible to have conditions depending if a specific value is present in an array. Please note that if conditions are combined using elseif as shown below the last TRUE condition will show.