php数组取模

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;
                                        }

本文标题:php数组取模
转载来源:http://lszwz.com/article/jespcp.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款