php数组取模

发布时间:2020-07-10 14:42:59 作者:liang3391
来源:网络 阅读:390
public function indexRecomHouse($area){
            $where = array();
            $where['a.isDel'] = '0';
            $where['a.status'] = '2';
            $where['a.auditstatus'] = '1';//已审核
            $where['a.salestatus'] = '0';//在售
            $where['a.isRecom'] = 'Y';
            $order = "a.verifyTime desc";
            $field = "a.esfId,c.shi,c.ting,c.chu,c.wei,a.price,a.buildingArea,b.fangAreaId,a.villageId,b.villageName";
            $data = $this->table($this->tablePrefix."house as a")->join("left join ".$this->tablePrefix."village as b on a.villageId=b.villageId")->join("left join ".$this->tablePrefix."village_pic_hsize as c on a.hsizeId=c.picId")->where($where)->field($field)->order($order)->limit(15)->select();
            if($data){
            $areaDb = D("FangArea");
            $housePicDb = D("HousePic");
            $num=0;
            foreach($data as $key => $val){
            $data[$key]['detailUrl'] = "http://esf.$area.qq.com/House1/detail?esfId=".$val['esfId'];
            $data[$key]['thumbUrl'] = $housePicDb->getThumb($val['esfId']);
            $data[$key]['areaName'] = $areaDb->getName($val['fangAreaId']);
            $data[$key]['zuhe'] = $val['shi']."室".($val['ting'] ? $val['ting']."厅" : "").($val['wei'] ? $val['wei']."卫" : "");
            $a=  explode('.', $val['buildingArea']);
                                if($a[1]>0){
                                $data[$key]['buildingArea'] =  $a[0].'.'.$a[1];   
                                }else {
                                $data[$key]['buildingArea'] =  $a[0];       
                                }
                                $b=  explode('.', $val['price']);
                                if($b[1]>0){
                                $data[$key]['price'] =  $b[0].'.'.$b[1];   
                                }else {
                                $data[$key]['price'] =  $b[0];       
                                }
                                //处理3层数据结构,每组下面5条数据
                                if($key%5 !=0){
                                $arr[$num][]=$data[$key];
                            }else {
                                $arr[$num+1][]=$data[$key];
                                $num +=1;
                            }
                       }
                        
                                            }
                                            return $arr;
                                        }
推荐阅读:
  1. 如何根据线程号获取模块信息
  2. Ruby取模探险记

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php 数组 取模

上一篇:mongodb效率快的原因

下一篇:ServletConfig是什么意思

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》