2017-06-27 6 views
0

私は$additional_infosという名前のarrayをphpファイルからスマートテンプレートファイルに割り当てます。スマートテンプレートのネストされた項目とキーを持つ配列のキーと値にアクセスしますか?

foreach ($results as $row) { 

    $additional_infos[] = array('informations_client' => $row['informations_client'], 'field_type' => $row['field_type']); 

} 

アレイプリントは、私はこのようなテンプレートでこれを表示することができ、この

Array 
(
    [0] => Array 
     (
      [informations_client] => Nom 
      [field_type] => 1 
     ) 

    [1] => Array 
     (
      [informations_client] => Prénom 
      [field_type] => 1 
     ) 

    [2] => Array 
     (
      [informations_client] => Adresse 
      [field_type] => 2 
     ) 
) 

のようなものです:私は希望

informations_client: Nom 

field_type: 1 

informations_client: Prénom 

field_type: 1 

{foreach name=outer item=contact from=$additional_infos} 
    <hr /> 
    {foreach key=key item=item from=$contact} 
     {$key}: {$item}<br /> 
    {/foreach} 
{/foreach} 

それは正常に動作しますに直接アクセスするまたはfield_typ eですが、スマートなエラーがあります。

私は私はそれをどのように行うことができます。この{$item. field_type}

のようなものを使用したいですか?

+1

をあなたは{[「field_type」] $アイテムを}使用することができます –

+0

@PavelPetrov私はこれに時間を費やし、最終的にはSOにいくつかの助けを見つけることにしました。ちょうど私の質問をした直後に、私はこれを1つのforeachで直接アクセスできることを発見しました。 '{$ contact.informations_client}' –

答えて

0

私はすぐに(私は時間のため、貼り付けた)質問をした後、解決策を見つけたので、私は私の質問を削除することを躊躇。

私はそれを助けることができるならば、私の答えを投稿好みます。多分それを向上させることができます。

{foreach name=outer item=contact from=$additional_infos} 

    {$contact.informations_client} - {$contact.field_type} 

{/foreach} 
関連する問題