码迷,mamicode.com
首页 > 编程语言 > 详细

php数组取模

时间:2016-07-01 16:44:11      阅读:508      评论:0      收藏:0      [点我收藏+]

标签: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/Linux@HeFei” 博客,转载请与作者联系!

php数组取模

标签:php数组取模

原文地址:http://liang3391.blog.51cto.com/178205/1794779

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!