moboileNumCat_calss_One

<?php 
 error_reporting(E_ALL);
/* @file:mobileNumCat_class.php
 *
 * @info:返回给定数字的类型
 *
 * @author:virhuiai
 *
 * @date:2013-03-26
 *
 * @time:02:28
 *
 * @modified:2013-03-26 06:35
 */

/*
AA
AAA 
AAAA 
AAAAA
-------------------------------

AABB##################
AABBB#########

ABAB #########
ABABAB#########

AAAB#########

ABBA #########
---------------------------------
ABC ###
AABBCC 
ABCABC

AABCC

ABAC 

BACA 

ABCAB
--------------------------------------
ABCD
ABCDABCD 
--------------------------------------
XAXAXAXA 
XXAAXXAA 
---------------------------------
XXABXXAB 
*/
class mobileNumCat{
	private $number="";
	private $pattern="";
	
	private $type = array(//'numCompany'=>"-4",
                           //'numCity'=>-1,
                           '12345678'=>-1,
                           '1234567'=>-1,
                           '123456'=>-1,
                               '12345'=>-1,
                               '1234'=>-1,
                               '123'=>-1,
                               '54321'=>-1,
                               '4321'=>-1,
                               '321'=>-1,
                            'aaaaaaa'=>-1,
	                        'aaaaaa'=>-1,
	                        'aaaaa'=>-1,
                           'aaaa'=>-1,
                           'aaa'=>-1,
                           'aa'=>-1,//-----------------------------
                           'ababab'=>-1,
                           'abab'=>-1,
                           'aabb'=>-1,
                           'aabbb'=>-1,
                           'aaab'=>-1,
                           'abba'=>-1,
                           'abcabc'=>-1,
                           'abc '=>-1,
                           'aabbcc '=>-1,
                           'aabcc'=>-1,
                           'abac '=>-1,
                           'baca '=>-1,
                           'abcab'=>-1,//--------------------------------------
                           'abcdabcd '=>-1,
                           'abcd'=>-1,//--------------------------------------'=>-1,
                           'xaxaxaxa '=>-1,
                           'xxaaxxaa '=>-1,//---------------------------------'=>-1,
                           'xxabxxab '=>-1
	);//数组,存放某个数学的规律
	 

	function __construct($number){
		$this->number = $number;
	}

	
	
	
	/*@modified:2013-03-26 16:44
	 * 
	 * 
	 * */
	public   function initPattern($type){// end at 2013 -3 -26 15:19
		switch ($type){
			case "aaaaaaa"://
				$this->pattern = '#(\d)\1{6}$#';
				break;
			case "aaaaaa"://
				$this->pattern = '#(\d)\1{5}$#';
				break;
			case "aaaaa"://
				$this->pattern = '#(\d)\1{4}$#';
				break;	
			case "aaaa":
				$this->pattern = '#(\d)\1{3}$#';
				break;
			case "aaa":
				$this->pattern = '#(\d)\1{2}$#';
				break;	
			case "aa"://---------------------------
				//(\d)\1
				$this->pattern = '#(\d)\1$#';
				break;
			
			case "aabb"://-----------------------est
				//(\d)\1(?!\1)(\d)\2$
				$this->pattern = '#(\d)\1(?!\1)(\d)\2$#';
				break;
			case "aabbb":
				//(\d)\1(?!\1)(\d)\2{2}$
				$this->pattern = '#(\d)\1(?!\1)(\d)\2{2}$#';
				break; 
			case "abab":
				//(\d)(?!\1)(\d)\1\2$
				$this->pattern = '#(\d)(?!\1)(\d)\1\2$#';
				break;
			case "ababab":
				//(\d)(?!\1)(\d)(\1\2)\3$
				//$this->pattern = '#(\d)\1{3}#';var_dump($this->$type);
				//break;
				$this->pattern = '#(\d)(?!\1)(\d)(\1\2)\3$#';
				break;
			case "aaab":
				//(\d)\1{2}(?!\1)\d$
				$this->pattern = '#(\d)\1{2}(?!\1)\d$#';
				break;
			case "abba":
				//(\d)(?!\1)(\d)\2\1$
				$this->pattern = '#(\d)(?!\1)(\d)\2\1$#';
				break;
			case "abc";//------------------type-------------
				//(\d)(?!\1)(\d)(?!\1)(?!\2)\d$
				$this->pattern = '#(\d)(?!\1)(\18950416176d)(?!\1)(?!\2)\d$#';
				break;				
			case "aabbcc":
				//(\d)\1(?!\1)(\d)\2(?!\1)(?!2)(\d)\3$
				$this->pattern = '#(\d)\1(?!\1)(\d)\2(?!\1)(?!2)(\d)\3$#';
				break;
			case "abcabc":
				//(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\1\2\3$
				$this->pattern = '#(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\1\2\3$#';
				break;
			case "aabcc":				
				//(\d)\1(?!\1)(\d)(?!\1)(?!\2)(\d)\3$
				$this->pattern = '#(\d)\1(?!\1)(\d)(?!\1)(?!\2)(\d)\3$#';
				break;
			case "abac":				
				//(\d)(?!\1)(\d)\1(?!\1)(?!\2)\d$
				$this->pattern = '#(\d)(?!\1)(\d)\1(?!\1)(?!\2)\d$#';
				break;
			case "baca":
				//(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\2
				$this->pattern = '#(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\2$#';
				break;
			case "abcab":
				//(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\1\2$
				$this->pattern = '#(\d)(?!\1)(\d)(?!\1)(?!\2)(\d)\1\2$#';
				break;
			case "birth"://-------------------------------------------------------------------
				$this->pattern = "#(19|20)[\d]{2}(1[0-2]|0?[1-9])(31|2[0-9]|1[0-9]|0?[0-9])$#";
				break;
			case "12345678":
				//(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){7}\d$
				$this->pattern ='#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){7}\d$#';
				break;
			case "1234567":
				//(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){6}\d$
				$this->pattern ="#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){6}\d$#";
				break;
			case "123456":
				//(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\d$
				$this->pattern ="#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\d$#";
				break;
								
			case "12345":
				//(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){4}\d$
				$this->pattern ="#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){4}\d$#";
				break;
			case "1234":
				$this->pattern ="#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\d$#";
				break;
			case "123":
				$this->pattern ="#(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\d$#";
				break;			
			case "54321";
				$this->pattern = '#(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){4}\d$#';
				break;
			case "4321";
				$this->pattern = '#(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){3}\d$#';
				break;
			case "321";
				$this->pattern = '#(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){2}\d$#';
				break;	
			case "xaxaxaxa":
				//(\d)(?!\1)(\d)(?!\2)(\d)\2(?!\2)\d\2(?!\2)\d\2$
				$this->pattern = '#(\d)(?!\1)(\d)(?!\2)(\d)\2(?!\2)\d\2(?!\2)\d\2$#';
				break;
			case "xxaaxxaa":
				//(\d)(\d)(?!\1)(?!\2)(\d)\3\d{2}\3{2}$
				$this->pattern = '#(\d)(\d)(?!\1)(?!\2)(\d)\3\d{2}\3{2}$#';
				break;
			case "xxabxxab";
				//(\d)(\d)(?!\1)(?!\2)(\d)(\d)(?!\1)(?!\2)\d{2}\3\4$
				$this->pattern = '#(\d)(\d)(?!\1)(?!\2)(\d)(\d)(?!\1)(?!\2)\d{2}\3\4$#';
		}
		
	}
	
	public function isMath($string){		
		$this->initPattern($string);
		//echo $this->pattern;
		
		if(preg_match_all($this->pattern, $this->number, $matches)){
			$this->type["$string"]=1;
			echo '<br>'.'<br>';
			return 1;
		}
		
		//var_dump($mathes);
		//print_r($matches);
		//var_dump($matches);
		
		
	}
	
	public function mathAll(){
		echo $this->number;
		echo "的全部规律";
		foreach ($this->type as $key => $value){
			//$this->isMath($key);
			if($this->isMath($key)){
				echo "类型".$key;
				//echo $value;
			}
			
		}
		
	}
	
	

}

//假定已经是合法帐号
//$test=new mobileNumCat(18950555555);
//$test->initPattern("aaa");
//$test->isMath("321");
//$test->mathAll();
//$test->geta();

?>

你可能感兴趣的:(moboileNumCat_calss_One)