日期:2014-05-17  浏览次数:20417 次

求php数组在Smarty模版页循环显示问题
$row2=explode('______',$conne->getRowsArray($sql));
$smarty->assign(array("array3"=>$row,"array4"=>$row2));

在此定义了数组
{%foreach item=i from=$array3%}
{%foreach item=j from=$array4%}//这里开始循环array,在这样里怎么才可以循环出数组的内容。
{%if $i!="guid"%}
<tr bgcolor="#EAEFFC">
  <td height="22" align="center">{%$i|replace:"__":" "%}</td>
  <td height="22" align="left">
  <input name="{%$i%}" type="text" id="{%$i%}" value="{%$j[0]%}" style="width:200px;" ><font color="#FCB4A5">(中文)</font> <input name="{%$i%}2" type="text" id="{%$i%}2" style="width:200px;" ><font color="#FCB4A5">(ENGLISH)</font>
  </td>
  </tr>
{%/if%}
{%/foreach%}
{%/foreach%}

------解决方案--------------------
探讨
{%foreach item=j from=$array%}//这里开始循环array,在这样里怎么才可以循环出数组的内容。

------解决方案--------------------
那说明你的当前的$j是字符串,那么你要{% $j %}就行了
------解决方案--------------------
探讨

读不到值,输出的全是大写A {%$j[0]%}

------解决方案--------------------
你可以现在php页面echo '<pre>';print_r($array);exit;看看里面的结构,根据结构在smarty中调用,要不你把echo出的结果发出来我帮你看看
------解决方案--------------------
哈哈,这个看着$j就是字符串Array呗
------解决方案--------------------
你可以这样调用
{% $j[0].guid %}这样,其他的一样,要多研究现,要多练习,那样很容易就找到规律了
------解决方案--------------------
上面说错了
是{% $j.guid %}