Dynamic variable from object |
[eluser]skribe[/eluser]
Hi folks: I'm having some difficulty in working how to achieve this. I have a (join) table that holds contact information. person contact_type contact_details Different people have different contact types and I want to be able to separate them out so I can do the update form of my CRUD. Is there a way for my to dynamically create variables from an object? Code: For instance: If not is there an alternative method? TIA skribe
[eluser]Jaketoolson[/eluser]
if I understand this correctly, you are referring to 'Variable Variables'? This is how I used to do it: Code: $options['stn_id'] = 77; This would result with the following variables being created: Code: $stn_id = 77; But see the link at the top for better methods.
[eluser]skribe[/eluser]
Thanks for the help. Apologies if I'm repeating myself and the help/code that you've supplied fixes this. I'm being dim (as usual =). This is what I'm trying to extract from: Code: Array ( [0] => stdClass Object ( [person_id] => 2 [contact_id] => 1 [details] => [email protected] [con_id] => 1 [type] => Email ) [1] => stdClass Object ( [person_id] => 2 [contact_id] => 2 [details] => 12345678 [con_id] => 2 [type] => Primary Phone ) ) I want to be able to extract the type/con_id and assign the relevant details to it. |
Welcome Guest, Not a member yet? Register Sign In |