#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    2

    New to objects, need help


    Signed up for an address verification service. They pass back an object and I am having a hell of a time trying to extract the ReturnCode value and stuff it in a var for porecessing.

    Code:
    $client = new SoapClient('http://pav3.cdyne.com/PavService.svc?wsdl');
     
    $param = array(
    	'FirmOrRecipient' => 'Cdyne'
    	,'PrimaryAddressLine' => '600 Pintail Ln'
    	,'SecondaryAddressLine' => ''
    	,'Urbanization' => ''
    	,'CityName' => 'Chesapeake'
    	,'State' => 'VA'
    	,'ZipCode' => '23320'
    	,'LicenseKey' => 'xxx' 
    );
    $result = $client->VerifyAddress($param);
     
    print_r($result);
  2. #2
  3. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,742
    Rep Power
    9397
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    2

    This


    stdClass Object ( [VerifyAddressResult] => stdClass Object ( [CityName] => CHESAPEAKE [Country] => USA [County] => CHESAPEAKE CITY [FirmNameOrRecipient] => CDYNE [PrimaryAddressLine] => 600 PINTAIL LN [ReturnCode] => 100 [SecondaryAddressLine] => [StateAbbreviation] => VA [Urbanization] => [ZipCode] => 23323-4015 ) )


    This is what i need to convert into a variable: [ReturnCode] => 100




    Originally Posted by requinix
    What does that print_r() output?
  6. #4
  7. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    Originally Posted by karnival800

    This is what i need to convert into a variable: [ReturnCode] => 100
    if you need that (array)value in a variable, than access that value and assign it to a variable.

    PHP Code:
    $newvariable $result['ReturnCode']; // will have the value of 100 in this case 
  8. #5
  9. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,742
    Rep Power
    9397
    $result is a stdClass object so
    PHP Code:
    $result-> 
    The next closest layer to the ReturnCode is the VerifyAddressResult object.
    PHP Code:
    $result->VerifyAddressResult-> 
    ReturnCode is right there.
    PHP Code:
    $result->VerifyAddressResult->ReturnCode 

    Comments on this post

    • aeternus agrees : great explaination thanks!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    2

    rad


    Originally Posted by requinix
    $result is a stdClass object so
    PHP Code:
    $result-> 
    The next closest layer to the ReturnCode is the VerifyAddressResult object.
    PHP Code:
    $result->VerifyAddressResult-> 
    ReturnCode is right there.
    PHP Code:
    $result->VerifyAddressResult->ReturnCode 

    thank you thank you thank you....
    i would like to research more about what we just did to be better at php. is this syntax specific to objects?
  12. #7
  13. Come play with me!
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,742
    Rep Power
    9397
    The -> thing? Yes.

    The best advice I have is for you to find yourself a book on PHP to read through. Or if you're comfortable finding good places online, some tutorial about PHP + whatever subject (like PHP+MySQL or PHP+OOP).

IMN logo majestic logo threadwatch logo seochat tools logo