From object to associative array
Export object properties as array: get_object_vars()
The function get_object_vars()
extracts properties or attributes from an object and creates an array with attribute names as keys and attribute values as values.
For example, if you have an object with 4 properties
If the property of an object is private
the property will not be exported by the function get_object_vars()
because of the scope. In the example look at the property $active
that is declared as private
. It is initialised as true
but it is not exported in the array
.