简体   繁体   中英

Smarty foreach loop building array

With a smarty foreach-loop I go through an array like this

{foreach name=aussen item=order_values from=$module_data}
  HEIAS_PARAMS.push(['order_article', '{$module_data.PRODUCTS_ID}']);
{/foreach}

The ouput is like this

HEIAS_PARAMS.push(['order_article', '1']);
HEIAS_PARAMS.push(['order_article', '2']);
HEIAS_PARAMS.push(['order_article', '3']);

How does the foreach-loop look to get an output like this

HEIAS_PARAMS.push(['order_article', '1,2,3']);
HEIAS_PARAMS.push(['order_article','{foreach name=aussen item=order_values from=$module_data}{$order_values.PRODUCTS_ID}{if ! $smarty.foreach.aussen.last},{/if}{/foreach}']);

我会按照这些思路写。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM