快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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数组取模
URL地址:http://6mz.cn/article/jespcp.html

其他资讯