我不确定我是否正确,但这里是问题而且很简单:
我有一个带代码的Smarty数组
<td>
{foreach from=$referrals item=referral}
{$referral.service} - {$referral.service|@count}</br>
{/foreach}
</td>
结果如下:Screenshot of array result
我的阵列是这样的:
Smarty_Variable Object (3)
->value = Array (29)
0 => Array (11)
id => "1433"
date => "25/12/2015"
service => "Деловен именик"
package => "Деловен именик"
userid => "469"
amount => "0.00"
billingcycle => "One Time"
amountdesc => "0,00 ден. One Time"
commission => "0,00 ден."
lastpaid => "Never"
status => "Active"
1 => Array (11)
id => "1434"
date => "25/12/2015"
service => "Лого со податоци"
package => "Лого со податоци"
userid => "469"
amount => "0.00"
billingcycle => "One Time"
amountdesc => "0,00 ден. One Time"
commission => "0,00 ден."
lastpaid => "Never"
status => "Active"
2 => Array (11)
id => "1435"
date => "25/12/2015"
service => "Реклама во црно-бела техника на 1/6 -..."
package => "Реклама во црно-бела техника на 1/6 -..."
userid => "469"
amount => "6160.00"
billingcycle => "One Time"
amountdesc => "6.160,00 ден. One Time"
commission => "1.232,00 ден."
lastpaid => "Never"
status => "Active"
3 => Array (11)
id => "1436"
date => "25/12/2015"
service => "Лого со податоци"
package => "Лого со податоци"
userid => "470"
amount => "0.00"
billingcycle => "One Time"
amountdesc => "1.848,00 ден. One Time"
commission => "369,60 ден."
lastpaid => "Never"
status => "Active"
4 => Array (11)
id => "1437"
date => "25/12/2015"
service => "Деловен именик"
package => "Деловен именик"
userid => "471"
amount => "0.00"
billingcycle => "One Time"
amountdesc => "0,00 ден. One Time"
commission => "0,00 ден."
lastpaid => "Never"
status => "Active"
我想要做的只是显示名称为“Деловенименик”的数组字符串或值,并从数组中隐藏。 所以最后得到这样的结果:Screenshot final result -wanted
答案 0 :(得分:1)
您是否尝试在{foreach}
循环中添加{if}
?
这可能就像在这里展示一样容易:
<td>
{foreach from=$referrals item=referral}
{if $referral.service eq "Деловен именик"}
{$referral.service} - {$referral.service|@count}</br>
{/if}
{/foreach}
</td>
但是,这是一种相当专业的方法,如果您想要过滤不同的内容,则必须编辑模板。如果这是更通用的解决方案的基础,那么最好在php中编写一些东西,可能是阵列中的另一个项目进行过滤。