dputlf5431
2019-03-14 14:32
浏览 57
已采纳

如何在Smarty / Prestashop中循环数组?

I use this code in Prestashop

{if (strpos($product.name, 'TVNUMBER1') !== false)}
    THIS PRODUCT IS IN SALE
{/if}

So whenever I want to display that certain products are in sale, I have to go line by line, specifying the same product i.e."TVNUMBER1". I want to be able to write an array detailing all the products I have in sale "TV1, TV2, TV3", and get a code like this:

{if (strpos($product.name, '$array') !== false)}
    THIS PRODUCT IS IN SALE
{/if}

I've tried similar examples found here, but I can't get them to work, either in Prestashop or in PHP testers online. It looks super simple, but I can't get around it.

图片转代码服务由CSDN问答提供 功能建议

我在Prestashop中使用此代码

  {if(strpos)  ($ product.name,'TVNUMBER1')!== false)} 
此产品已售出
 {/ if} 
   
 
 

所以每当我想要的时候 为了显示某些产品在销售,我必须逐行,指定相同的产品,即“TVNUMBER1”。 我希望能够编写一个数组详细介绍我销售的所有产品“TV1,TV2,TV3”,并获得如下代码:

   {if(strpos($ product.name,'$ array')!== false)} 
此产品已售出
 {/ if} 
   
 \ 我已经尝试过类似的例子,但我无法让它们在Prestashop或在线PHP测试人员中工作。 它看起来非常简单,但我无法解决它。 
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题