开发者

PHP results not displayed in smarty template

I have a variable $my_arr whose var_dump($my_arr) value is

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" } } 

In smarty I tried

{foreach name = fe1 item = k from = arr}
{$k->prod_index}    
{/foreach}

But it is not showing any result .


Assuming you're already assigning the array to smarty like:

$smarty->assign( "arr", $my_arr );

You need to use the "." syntax, like:

{foreach name = fe1 item = k from = arr}
{$k.prod_index}    
{/foreach}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜