Click here to Skip to main content
14,357,880 members
Rate this:
Please Sign up or sign in to vote.
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:
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

It must be simply

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


—SA
   
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100