Suraj Hazarika
Suraj Hazarika

Reputation: 667

Array not displaying in smarty

I have an array $cand_detail . print_r($cand_detail) shows :

Array ( [0] => Array ( [0] => stdClass Object ( [cand_f_name] => Nitish [cand_l_name] => Dolakasharia [cand_email] => [email protected] [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] => [email protected] [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 ) ) ) 

Now I assigned the values to smarty :

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

And in smarty :

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

But it is not showing the first names of the candidates , it is coming black.

Upvotes: 1

Views: 104

Answers (1)

Paul Lammertsma
Paul Lammertsma

Reputation: 38252

The item in the array is an object, so you need to point to the field using ->. Also, it appears you are using a two-dimensional array.

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

Upvotes: 1

Related Questions