Page 1 of 1

Retrieving data member names from a PHP Object

Posted: Mon Jun 01, 2009 12:48 pm
by kuksenkate
Hi,

So, if I have an object of the form:

stdClass Object
(
[1909] => 1
[1950] => 1
[1977] => 1
[1982] => 2
[1984] => 1
[1986] => 1
....

How do I get a list of the data member names (like "1909, 1950, etc"). Note , they may be dates here, but are ARBITRARY. completely.

I ask because I have this JSON feed:
{"1909":1,"1950":1,"1977":1,"1982":2,"1984":1,"1986":1,"19....
But I only care about the strings, not the numbers they map to.
I don't want to hack this together by parsing the JSON string myself (because input is arbitrary, and this script needs to be neat, and I don't want to reinvent the wheel).

Thank you kindly for help.
-alex

Re: Retrieving data member names from a PHP Object

Posted: Mon Jun 01, 2009 12:57 pm
by requinix
I bet there's a function to get class vars somewhere.

Re: Retrieving data member names from a PHP Object

Posted: Mon Jun 01, 2009 1:15 pm
by kuksenkate
thanks - exactly what i was looking for.