does the below template do what you want?
Code:
program:
f = field('#taglike');
icons = '';
sep = ':';
for keyword in 'foo,bar,test':
val = contains(f, keyword, strcat(keyword, '.png'), '');
if val then
icons = list_union(icons, val, sep)
fi
rof;
ifempty(icons, 'unknown.png')