codeBYmahesh codeBYmahesh - 4 years ago 543
Smarty Question

how to print an array in smarty?

I have an array:

$team_details = Array ( [id] => 1 [name] => doge_finder [total_rewards] => 52.00524500 [desciption] => team is only of doge miners [created_by] => 20 );

/* assigning to a smarty template */
$smarty->assign("team_record", $team_details);

In template file:

{foreach from= $team_record key=team item=trecord}

In result output must be "doge_finder", but I got first initial character of each record in array ie. "1 d 5 t 2"

how can I resolve this problem?

Answer Source

You dont have to user {foreach} if you just want to print one associative array. Just use $array.key format.

In this case, you should print using


If you have multiple associative array. You can use:

{foreach from=$team_record key=team item=record}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download