php中foreach循环里面做if判断

奔波在生活路上 2015-11-26 11:38:41

<if condition='mb_strlen(zhuye_item.note5uuidHeadIdx) gt 10'>{$zhuye_item.smallUrl}<else/>{$zhuye_item.note5uuidHeadIdx}</if>
[0] => Array
(
[noteId] => 389
[deleteFlag] => 0
[note5uuid] => 300000186
[note5uuidAnonym] =>
[note5uuidHeadIdx] => [{"bigKey":"","smallUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBfCUHwTAAA_pWNnYXw019.png","smallKey":"","bigUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBeBcOe4AAGAT87yCLw740.png"}]
[note2uuid] => 300000186
[note2uuidHeadIdx] => [{"bigKey":"","smallUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBfCUHwTAAA_pWNnYXw019.png","smallKey":"","bigUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBeBcOe4AAGAT87yCLw740.png"}]
[note2uuidAnonym] =>
[sendTime] => 1448508925
[type] => 0
[content] => 涂抹急急急急急急了踏踏实实试图投资
[replyCnt] => 1
[praiseCnt] => 0
[praiseAble] => 1
[bigKey] =>
[bigUrl] => http://xxx/M00/02/1A/wKgBeVZVpBeBcOe4AAGAT87yCLw740.png
[smallKey] =>
[smallUrl] => http://xxx/1A/wKgBeVZVpBfCUHwTAAA_pWNnYXw019.png
)

[1] => Array
(
[noteId] => 366
[deleteFlag] => 0
[note5uuid] => 0
[note5uuidAnonym] => 春野樱
[note5uuidHeadIdx] => 91
[note2uuid] => 300000186
[note2uuidHeadIdx] => [{"bigKey":"","smallUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBfCUHwTAAA_pWNnYXw019.png","smallKey":"","bigUrl":"http://xxx/M00\/02\/1A\/wKgBeVZVpBeBcOe4AAGAT87yCLw740.png"}]
[note2uuidAnonym] =>
[sendTime] => 1448505049
[type] => 1
[content] => 0
[replyCnt] => 5
[praiseCnt] => 0
[praiseAble] => 1
)

大概就是两种数组,一种是JSON串,一种就是纯数字的。问题是现在页面foreach循环的时候判断这个长度没有用呢。
...全文
380 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
判断里面是 <foreach name="zhuye" item="zhuye_item" key="zhuye_key"> <div>头像: <if condition='mb_strlen(zhuye_item.note5uuidHeadIdx) gt 10'>{$zhuye_item.smallUrl}<else/>{$zhuye_item.note5uuidHeadIdx}</if> 用户: {$zhuye_item.note5uuidAnonym} <eq name="zhuye_item.type" value="0"> 评论: {$zhuye_item.content}</eq><eq name="zhuye_item.type" value="1"> 打分:{$zhuye_item.content}</eq></div> </foreach> 循环里头像这块判断不成功
  • 打赏
  • 举报
回复
解决了,直接在返回的数组里面加了一个数组长度,页面取值的时候eq一下就好了。

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧