Authored by tmq

右边banner

... ... @@ -153,16 +153,18 @@ EOL;
$banners = $this->view->rightBanners;
$temp = array();
$len = count($banners);
if($len >=3)
if($len >3 && is_numeric($len)&(!($len&1)))
{
//随机选择出两个元素
$temp=array_rand($banners,2);
foreach($temp as $val){
$data_last[]=$banners[$val];
}
// $temp = array_slice($banners, 0,1);
// $pos = rand(1, $len-1);
// $banners = array_merge($temp, array_slice($banners, $pos, 2));
}
if($len >=3 && is_numeric($len)&($len&1)){
$temp = array_slice($banners, 0,1);
$pos = rand(1, $len-1);
$data_last = array_merge($temp, array_slice($banners, $pos, 1));
}
foreach($data_last as $banner):
$res_size = json_decode($banner['res_size'], true);
... ...