代码里面有 oneline 的数据和 twoline 的数据,怎么把这两组数据并集起来
程序员文章站
2022-05-19 23:45:30
...
代码里面有 oneline 的数据和 twoline 的数据,如何把这两组数据并集起来?
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('/([\s\S]*?)/i',$content,$pregArray);
if(count($pregArray)){
foreach($pregArray[0] as $value){
preg_match_all('//i',$value,$v); ');
$ipVal = $this->strSub($v[0][3],'fa">','
$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">',''));
$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) 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;
}
代码里面有 oneline 的数据和 twoline 的数据,如何把这两组数据并集起来,谢谢!
------解决思路----------------------
// $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
?>
------解决思路----------------------
两段的数据都写到 $array 中了,本来就是在一起的
只不过第二段的可能会覆盖第一段的
相关文章
相关视频
- 详解win10下PHP的安装配置(以php5.6为...
- php Swoole实现毫秒定时计划任务(详解)
- 【DTM】PHP协程客户端v0.1 beta版本发...
- PHP中类的理解和应用[一]_PHP教程
- 代码里面有 oneline 的数据和 twolin...
专题推荐
- 独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
- 玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
- 天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论