I\'m trying to write a function that formats every (string) member/variable in an object, for example with a callback function. The variable names are unknown to me, so it m
You are looking for get_object_vars / get_class_methods (the first gets the variables, the second the method names).
use get_object_vars() to get an associative array of the members, and use the functions you mentioned.
btw, you can also do a foreach on an object like you would on an array, which is sometimes useful as well.
You can use get_object_vars()
, but if you need more control, try using reflection. It's slower than get_object_vars()
(or get_class_methods()
for that matter), but it's much more powerful.