public function line($config,$qq='',$data=array()){ $array = array(); $line = $config['line']; $url = trim($config[$line]); if($line == 'oneline' && $qq != ''){ $content = $this->proGetCont($url.'/index.php?m=account&c=index&a=search&q='.$qq); preg_match_all('/<tr>([\s\S]*?)<\/tr>/i',$content,$pregArray); if(count($pregArray)){ foreach($pregArray[0] as $value){ preg_match_all('/<td([\s\S]*?)<\/td>/i',$value,$v); $ipVal = $this->strSub($v[0][3],'fa">','</td>'); $ipid = M('iplib')->where('ipval = \''.$ipVal.'\'')->find()['id']; if(!$ipid){ $ipid = M('iplib')->add(array('ipval'=>$ipVal,'namelist'=>'1')); } $timsInt = strtotime($this->strSub($v[0][4],'fa">','</td>')); $boolTure=true; foreach($data as $d){ if(($d['jbtime'] == $timsInt) && ($ipid == $d['jbip'])){ $boolTure = false; } } if($boolTure || count($data) ==0){ $array[] = array( 'jbip'=>$ipid, 'jbtime'=>$timsInt, 'number'=>$qq, 'class'=>'1', 'type'=>'4', 'whitelist'=>'0' ); } } $rel = M('number')->addAll($array); } } if($line == 'twoline' ){ $number = ''; $class = '1'; if($qq != ''){ if(!is_numeric($qq) || (strlen($qq) < 5) || (strlen($qq) > 13) ){ $this->error('您查询的QQ号格式错误!'); return $data; } $content = $this->proGetCont($url.'/form.php','qq='.$qq); $number = $qq; } if($content){ $type = M('type')->select(); $typeArray = array(); foreach($type as $v){ $typeArray[trim($v['name'])] = $v['id']; } preg_match_all('/{([\s\S]*?)}/i',$content,$pregArray); if(count($pregArray)){ foreach($pregArray[0] as $k => $value){ $ipVal = $this->strSub($value,'myip":',',"date'); $ipVal = str_replace('"','',$ipVal); $ipid = M('iplib')->where('ipval = \''.$ipVal.'\'')->find()['id']; if(!$ipid){ $ipid = M('iplib')->add(array('ipval'=>$ipVal,'namelist'=>'1')); } $timsInt = strtotime($this->strSub($value,'date":"','","typetext')); $boolTure=true; foreach($data as $d){ if(($d['jbtime'] == $timsInt) && ($ipid == $d['jbip'])){ $boolTure = false; } } if($boolTure || count($data) ==0){ $array[$k]['jbip'] = $ipid; $array[$k]['jbtime'] = $timsInt; if($class == '1'){ $type = trim($this->unicode_decode($this->strSub($value,'typetext":"','","qq1'))); } if($class == '2'){ $type = trim($this->unicode_decode($this->strSub($value,'typetext":"','","ww1'))); } $array[$k]['type'] = (array_key_exists($type,$typeArray))?$typeArray[$type]:'其他'; $array[$k]['number'] = $number; $array[$k]['class'] = $class; $array[$k]['whitelist'] = '0'; } } $rel = M('number')->addAll($array); } } } } if(count($array)){ foreach($array as $a){ $data[]=$a; } } return $data; }
<?php // $a = 1 2 3 4 $union = // $b = 2 4 5 6 array_merge( array_intersect($a, $b), // 2 4 array_diff($a, $b), // 1 3 array_diff($b, $a) // 5 6 ); // $u = 1 2 3 4 5 6?>
2 つの段落のデータは、元々は一緒に $array に書き込まれます
が、2 番目の段落が最初の段落を上書きする可能性があります
します。まずは試してみてください、お二人に感謝します。