使用下面代码即可
{if $searchkeywords} <div class="hotwords"> {foreach from=$searchkeywords item=val name=foo} <a {if $smarty.foreach.foo.first}class="text-red"{/if} href="search.php?keywords={$val|escape:url}" target="_blank">{$val}</a> {/foreach} </div> {/if}