Table of Contents
代码里面有 oneline 的数据和 twoline 的数据,如何把这两组数据并集起来?
Jun 23, 2016 pm 01:42 PM
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; }
Copy after login
代码里面有 oneline 的数据和 twoline 的数据,如何把这两组数据并集起来,谢谢!
回复讨论(解决方案)
<?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?>
Copy after login
两段的数据都写到 $array 中了,本来就是在一起的
只不过第二段的可能会覆盖第一段的
我先试试,多谢两位。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot tools Tags

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
