2019独角兽企业重金招聘Python工程师标准>>>
smarty二维foreach示例[顺代一维数组],再次加强版
WEB2.0 root 2009-4-9 10:46 评论(0) 阅读(682) 大 | 中 | 小
- {foreach item=rec from=$result namename=name}
- <!-- begin -->
- <li class="clearfix">
- <div class="lw_l">
- <div class="numOnetoten"><em
- >{$smarty.foreach.name.iteration}</em></div><a href="#"><img src="{$rec.potourl}"/></a></div>
- <div class="lw_r">
- <p class="name"><a href="#">{$rec.name}</a></p>
- <p class="step">
- {foreach item=imgsrcurl from
- =$rec.imgsrc}
- <img
- src="http://simg.sinajs.cn/a
- pp/images/renyuan/{$imgsrcurl}" />
- {/foreach}
- </p>
- <p class="count"><a href="#">²é¿´ÀñÎï</a></p>
- </div>
- </li>
- {/foreach}
- Array
- (
- [0] => Array
- (
- [name] => 赵再丰
- [uid] => 1052833673
- [score] => 442222
- [potourl] => http://p2.sinaimg.cn/1052833673/50/
- [imgsrc] => Array
- (
- [0] => renyuan_level_1.gif
- [1] => renyuan_level_1.gif
- [2] => renyuan_level_1.gif
- )
- )
- [1] => Array
- (
- [name] => 向东
- [uid] => 1548940117
- [score] => 157829
- [potourl] => http://p6.sinaimg.cn/1548940117/50/1233908532
- [imgsrc] => Array
- (
- [0] => renyuan_level_1.gif
- )
- )
- [2] => Array
- (
- [name] => 笨蛋
- [uid] => 1584778420
- [score] => 7842
- [potourl] => http://p5.sinaimg.cn/1584778420/50/
- [imgsrc] => Array
- (
- [0] => renyuan_level_3.gif
- [1] => renyuan_level_3.gif
- [2] => renyuan_level_3.gif
- [3] => renyuan_level_3.gif
- [4] => renyuan_level_3.gif
- )
- )
- )
一维数组直接用点即可:
- $flag = $msgobj->getmyinfo($returnvalues,$uid);
- $this->responseContext["myinfo"] = $returnvalues;
显示HTML:
- {$myinfo.name}
- Array
- (
- [name] => 向东
- [myicon] => http://p6.sinaimg.cn/1548940117/50/1233908532
- [gapscore] => 77
- [imgnumsrc] => Array
- (
- [0] => renyuan_level_3.gif
- )
- )
三维数组形式:
- Array (2)
- 1 => Array (10)
- 0 => Array (33)
- f_Id => "4"
- f_OptionId => "7"
- f_IterBugId => "1110034731009015555"
- ...
- 2 => Array (10)
- 0 => Array (33)
- f_Id => "21"
- f_OptionId => "17"
- f_IterBugId => "1110034731009015888"
- ...
Html用Smarty循环出来如下:
- <{foreach keykey=key itemitem=item from=$allNeedTestInfoArr namename=name}>
- <div style='margin-left:12.0pt;margin-top:3.75pt;margin-right:3.75pt;margin-bottom:.75pt'>
- <p class=MsoNormal style='mso-line-height-alt:4.5pt'><span lang=EN style='font-size:12.0pt;mso-ansi-language:EN;'>第<{$smarty.foreach.name.iteration}>批次问题:<o:p></o:p></span></p>
- <{foreach key=key2 item=item2 from=$item name=name2}>
- <span style="font-size:10.0pt;font-family:"微软雅黑","sans-serif";color:black"><{$smarty.foreach.name2.iteration}>.<a target="_blank" href="http://tapd.oa.com/v3/<{$item2.f_Project_Id}>/bugtrace/bugs/view?bug_id=<{$item2.f_IterBugId}>"><{$item2.f_Title}></a>
- </span>
- <br>
- <{/foreach}>
- </p>
- </div>
- <{/foreach}>