簡體   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