Click here to Skip to main content
16,008,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello there,

I'm trying to retrieve values from an object. I'm using jFormer for form validation and creation and I have an address component.

Now on submit, I read the address component and input what is read into a variable $address, which returns the following:
print_r($address); //returns the following:

stdClass Object ( [addressLine1] => Test Address [addressLine2] => [city] => Test Road [state] => Test City [zip] => Test Post [country] => MT ) 


According to the documentation on jformer, the address returns the following:
C#
Value Returned

Object

Keys: { addressLine1, addressLine2, city, state, zip, country }


What I would like is to read each variable separately. I have read lots of php manual sections regarding keys, but haven't found a solution yet ;/

So in terms how would I set ex addressLine1 to the variable $Address1.

Please help. Thanks!
Posted

1 solution

It must be simply

PHP
$addr1 = $address->addressLine1;
$addr2 = $address->addressLine2;
$city = $address->city;
$state = $address->state;
//...


—SA
 
Share this answer
 
Comments
Necron8 24-Dec-11 5:52am    
Thanks man!. I've been trying on getting this to work for hours and seeing such a simple solution makes me laugh or cry -_-.

Thanks a lot!
Sergey Alexandrovich Kryukov 24-Dec-11 16:58pm    
Don't cry just yet, there will be more thing to come... :-)
Cheers,
--SA
Necron8 25-Dec-11 6:54am    
Haha sure will. This jformer is killing me! Happy Christmas and a new Year to All! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900