$smarty -> assign("s_ret",$sret);
$smarty -> display("info_contact.html");一个数组传给了 info_contact.html  如何在info_contact.html   上取单独的某个值呢?  比如,ID   foreach 是循环出来所有值  不是单独一个。

解决方案 »

  1.   

    你的$sret是二维数组?{section name=cent loop=$arrList}
    <p>{if $arrList[cent].id eg "123"}
          $arrList[cent].id
       {/if}
    </p>
    {/section}
      

  2.   


    不循环  只是得到ID这个值。(这里ID的值相同)
      

  3.   

    也可以直接传 $smarty -> assign("s_ret",$sret["id"]);
      

  4.   

    你要是知道id是第几个,那就:
    {$list[n]['id']}
    不然,在不确定二维数组中取值?真心蒙了
      

  5.   

    $smarty -> assign("s_ret",$sret);
    $smarty -> display("info_contact.html");$sret是个数组,在info_contact.html中{$s_ret}输出的就会是整个数组
    {$s_ret['ID']}也可以用{$s_ret.ID}就可以把其中的ID取出来了
    现在没有实验呢,你可以试一个,ThinkPHP模板中可以用这个输出的,应该差不多吧!
      

  6.   

    如果不是需要循环出来的数组的话,你直接在html里面{$s_ret.id}就可以了。
      

  7.   

    直接输出数组{$s_ret[0][1]}
      

  8.   

    是的,关键是你在之前assign下变量就可。就不需要在显示的时候循环了。
      

  9.   

    很简单,{$s_ret.id}或者{$s_ret[0].id}