这是我获取所有tld(域)价格列表的方法:
{foreach from=$tldpricelist item=tldprice}
TLD: {$tldprice.tld} - Price: {$tldprice.register}
{/foreach}
我希望只显示我在数组中保留的某些tld的价格:
{$pricelist=["co.uk","me.uk","org.uk","uk","london","com","info","net","biz","org","name","eu"]}
我对SMARTY非常陌生,我确信应该有一些简单的方法只为某些tld调用$tldpricelist
。
答案 0 :(得分:0)
尝试in_array fucntion。我在你的代码中添加了一张支票。如果tld将在您的$ pricelist数组中,那么它将显示TLD,否则价格不会。
{$pricelist=["co.uk","me.uk","org.uk","uk","london","com","info","net","biz","org","name","eu"]}
{foreach from=$tldpricelist item=tldprice}
{if in_array($tldprice.tld,$pricelist}
TLD: {$tldprice.tld} - Price: {$tldprice.register}
{/if}
{/foreach}