不顯示我有一個變量$my_arr
其var_dump($my_arr)
值PHP導致智者模板
array(3) { [0]=> object(stdClass)#6 (9) { ["prod_index"]=> string(1) "1" ["prod_code"]=> string(4) "amp1" ["prod_name"]=> string(11) "Amplifier A" ["prod_price"]=> string(6) "100.00" ["frequency"]=> string(1) "2" ["gain"]=> string(1) "2" ["gain_variation"]=> string(3) "0.2" ["noise"]=> string(1) "2" ["power"]=> string(2) "10" } [1]=> object(stdClass)#7 (9) { ["prod_index"]=> string(1) "3" ["prod_code"]=> string(4) "amp1" ["prod_name"]=> string(13) "Amplifire1.33" ["prod_price"]=> string(6) "133.00" ["frequency"]=> string(4) "2.12" ["gain"]=> string(1) "2" ["gain_variation"]=> string(3) "0.2" ["noise"]=> string(1) "2" ["power"]=> string(2) "10" } [2]=> object(stdClass)#8 (9) { ["prod_index"]=> string(1) "4" ["prod_code"]=> string(4) "amp1" ["prod_name"]=> string(13) "Amplifier1.45" ["prod_price"]=> string(6) "150.00" ["frequency"]=> string(4) "2.99" ["gain"]=> string(1) "2" ["gain_variation"]=> string(3) "0.2" ["noise"]=> string(1) "2" ["power"]=> string(2) "10" } }
在智者我試圖
{foreach name = fe1 item = k from = arr}
{$k->prod_index}
{/foreach}
但它沒有顯示任何結果。
而你是如何通過該變量從PHP到模板? – zerkms
是不是應該從'= $ arr'?而據我所知,在Smarty的3,你可以使用PHP的語法:'{$的foreach作爲改編$ķ}' – Catalin
@Catalin感謝克特林....指出我的愚蠢的錯誤感謝! –