数组不显示在smarty中

时间:2011-11-17 11:17:50

标签: php smarty

我有一个数组$cand_detailprint_r($cand_detail)显示:

Array ( [0] => Array ( [0] => stdClass Object ( [cand_f_name] => Nitish [cand_l_name] => Dolakasharia [cand_email] => nitish@yahoo.com [cand_password] => *5D47AA16D3C7B8B748B89E16DE11C54CB0CF37DF [cand_phone] => 7878777887 [cand_qualification] => ba [cand_industry] => [cand_experience_yr] => 0 [cand_experience_mn] => 5 [cand_message] => [cand_id] => 1 [cand_resume] => resume/tourist map details.doc ) ) [1] => Array ( [0] => stdClass Object ( [cand_f_name] => Anupam [cand_l_name] => Baruah [cand_email] => anupam@gmail.com [cand_password] => *5D47AA16D3C7B8B748B89E16DE11C54CB0CF37DF [cand_phone] => 45465465 [cand_qualification] => eng_mch [cand_industry] => [cand_experience_yr] => 3 [cand_experience_mn] => 4 [cand_message] => [cand_id] => 2 [cand_resume] => resume/tourist map details.doc ) ) ) 

现在我将值分配给smarty:

$this->assign_values('cdetail',$cand_detail);

而且聪明:

{foreach name = feach item = v from = $cdetail}
    First Name : {$v.cand_f_name}<br />
{/foreach}

但是它没有显示候选人的名字,它会变黑。

1 个答案:

答案 0 :(得分:1)

数组中的项是一个对象,因此您需要使用->指向该字段。此外,您似乎正在使用二维数组。

{foreach name = feach item = clist from = $cdetail}
    {foreach item = v from = $clist}
        First Name : {$v->cand_f_name}<br />
    {/foreach}
{/foreach}