Return to Snippet

Revision: 46822
at May 26, 2011 03:29 by mariraj


Initial Code
function object_2_array($result){
		   $array = array();
		   foreach ($result as $key=>$value)
		   {
			  # if $value is an object then
			  if (is_object($value))
			  {
				#run the $value through the function again.
				$array[$key]=object_2_array($value);
			  }
			  # if $value is an array then
			  if (is_array($value))
			  {
				#run the $value through the function again??????
				$array[$key]=object_2_array($value);
			  }
			  # if $value is not an array then (it also includes objects)
			  else
			  {
				$array[$key]=$value;
			  }
			}
			return $array;
		} 



		function checkcreditcardValidity( $cardno = 0){
		
				$client = new soapClient('http://ws.cdyne.com/creditcardverify/luhnchecker.asmx?wsdl');
				
				$result = $client->CheckCC(array("CardNumber" => $cardno));
				$arr = object_2_array($result);
				$arr1 = object_2_array($arr['CheckCCResult']);
		
				//$arr1['CardType'];
				if( $arr1['CardValid'] != '1' ){									
					 return false;		
				}
				return true;
		}
		
	   /*----------------------------------------------------------------------------*/

Initial URL

                                

Initial Description
Credit Card Verification

Initial Title
Credit Card Verification

Initial Tags

                                

Initial Language
PHP