繁体   English   中英

TPL中的Smarty数组

[英]Smarty array in tpl

在PHP文件中,当print_r看起来像array([response_code] => 100, [products[0][price]] => 149.00 [products[0][name]] => 'Blah blah.....')并由此分配给:

$smarty->assign('order_details', $order_details); //$order_details is the array above.

现在在模板上,我可以通过以下方式显示response_code:

{$order_details.response_code}

但是,如何显示产品名称? 我试过了:

  1. {$order_details.products[0][name]}
  2. {$order_details.products[0].name}
  3. {$order_details.products.0.name}

但是没有任何效果。 请一些帮助...

试试这个将起作用:

$smarty->assign('order_details', $order_details); //$order_details is the array above.

现在在模板上,我可以通过获取像这样的数组值来显示:

{section name=i loop=$order_details}

{$order_details[i].name}

{/section}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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