static function IsValidCreditCard($cc_num, $type = "") 
	{
		
		if($type == "American") {
			$denum = "American Express";
		} elseif($type == "Dinners") {
			$denum = "Diner's Club";
		} elseif($type == "Discover") {
			$denum = "Discover";
		} elseif($type == "Master") {
			$denum = "Master Card";
		} elseif($type == "Visa") {
			$denum = "Visa";
		}
		
		$verified = false;
		
		if($type == "American" || $type == "") {
			$pattern = "/^([34|37]{2})([0-9]{13})$/";//American Express
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Dinners" || $type == "") {
			$pattern = "/^([30|36|38]{2})([0-9]{12})$/";//Diner's Club
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Discover" || $type == "") {
			$pattern = "/^([6011]{4})([0-9]{12})$/";//Discover Card
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Master" || $type == "") {
			$pattern = "/^([51|52|53|54|55]{2})([0-9]{14})$/";//Mastercard
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		} 
		
		if($type == "Visa" || $type == "") {
			$pattern = "/^([4]{1})([0-9]{12,15})$/";//Visa
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
		}
		
		return $verified;
		
	}
static function IsValidCreditCard($cc_num, $type = "") 
	{
		
		if($type == "American") {
			$denum = "American Express";
		} elseif($type == "Dinners") {
			$denum = "Diner's Club";
		} elseif($type == "Discover") {
			$denum = "Discover";
		} elseif($type == "Master") {
			$denum = "Master Card";
		} elseif($type == "Visa") {
			$denum = "Visa";
		}
		
		$verified = false;
		
		if($type == "American" || $type == "") {
			$pattern = "/^([34|37]{2})([0-9]{13})$/";//American Express
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Dinners" || $type == "") {
			$pattern = "/^([30|36|38]{2})([0-9]{12})$/";//Diner's Club
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Discover" || $type == "") {
			$pattern = "/^([6011]{4})([0-9]{12})$/";//Discover Card
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		}
		
		if($type == "Master" || $type == "") {
			$pattern = "/^([51|52|53|54|55]{2})([0-9]{14})$/";//Mastercard
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
			
		} 
		
		if($type == "Visa" || $type == "") {
			$pattern = "/^([4]{1})([0-9]{12,15})$/";//Visa
			if (preg_match($pattern,$cc_num)) {
				$verified = true;
			}
			
		}
		
		return $verified;
		
	}
static function IsValidCreditCard ( $ cc_num , $ type = "" ) { if ( $ type == "American" ) { $ denum = "American Express" ; } elseif ( $ type == "Dinners" ) { $ denum = "Diner's Club" ; } elseif ( $ type == "Discover" ) { $ denum = "Discover" ; } elseif ( $ type == "Master" ) { $ denum = "Master Card" ; } elseif ( $ type == "Visa" ) { $ denum = "Visa" ; } $ verified = false ; if ( $ type == "American" || $ type == "" ) { $ pattern = "/^([34|37]{2})([0-9]{13})$/" ; //American Express
 if ( preg_match ( $ pattern , $ cc_num ) ) { $ verified = true ; } } if ( $ type == "Dinners" || $ type == "" ) { $ pattern = "/^([30|36|38]{2})([0-9]{12})$/" ; //Diner's Club
 if ( preg_match ( $ pattern , $ cc_num ) ) { $ verified = true ; } } if ( $ type == "Discover" || $ type == "" ) { $ pattern = "/^([6011]{4})([0-9]{12})$/" ; //Discover Card
 if ( preg_match ( $ pattern , $ cc_num ) ) { $ verified = true ; } } if ( $ type == "Master" || $ type == "" ) { $ pattern = "/^([51|52|53|54|55]{2})([0-9]{14})$/" ; //Mastercard
 if ( preg_match ( $ pattern , $ cc_num ) ) { $ verified = true ; } } if ( $ type == "Visa" || $ type == "" ) { $ pattern = "/^([4]{1})([0-9]{12,15})$/" ; //Visa
 if ( preg_match ( $ pattern , $ cc_num ) ) { $ verified = true ; } } return $ verified ; }
Returns true if the provided credit card appears to be valid.  If type is
provided, then the validation makes sure it is valid for that specific
type, otherwise it just makes sure it is valid for any type

@param string credit card number
@param string type [optional] (American, Dinners, Discover, Master, Visa)
@return bool
Returns true if the provided credit card appears to be valid . If type is provided then the validation makes sure it is valid for that specific type otherwise it just makes sure it is valid for any type