PHP analyzing, handling and converting some object to a stdClass
<p>In our backoffice we have a core-system that generates models from the DB. When returning one object we make an instance of stdClass. All the columns from the query-result are set as proprties and when finished processing the query-result the stdClass-object is converted into a (we call it) Decorator-class. Basically the Decorator-class has one proprty $_oObject where the stdClass is stored into. We do this gain control over dynamically created objects. This works all fine.</p>

<p>However, I'm working on a webserver using SOAP. The webservice returns the whole Decorator-object (could possibly have sub-objects, also being Decorator objects, and sub-sub object.. and so on). This structure works perfectly fine with our internal system because we have control over the Decorator-object but for the outside world I want to revert the Decorator-object-structure into a stdClass instance with sub-classes also being stdClasses. Basically I want to remove all the 'nodes' in the print_r-result containing Decorator.</p>

<p>Any ideas how to achieve what I want (see results below). PHP's <code>get_object_vars</code> doesn't return anything and actually I'm stuck..</p>

<p>My sample data:</p>

<pre><code>Decorator Object
(
    [oClass:Decorator:private] =&gt; stdClass Object
        (
            [Id] =&gt; 1
            [FAQCategoryId] =&gt; 1
            [TitleId] =&gt; 1
            [ContentId] =&gt; 2
            [Views] =&gt; 226
            [DateCreated] =&gt; 2011-10-31 11:17:44
            [DateModified] =&gt; 
            [Title] =&gt; My title..
            [Content] =&gt; My content..
            [AttachmentSet] =&gt; Array
                (
                    [0] =&gt; Decorator Object
                        (
                            [oClass:Decorator:private] =&gt; stdClass Object
                                (
                                    [Id] =&gt; 1
                                    [LanguageId] =&gt; 1
                                    [FAQItemId] =&gt; 1
                                    [Attachment] =&gt; file1.pdf
                                )

                        )

                    [1] =&gt; Decorator Object
                        (
                            [oClass:Decorator:private] =&gt; stdClass Object
                                (
                                    [Id] =&gt; 2
                                    [LanguageId] =&gt; 1
                                    [FAQItemId] =&gt; 1
                                    [Attachment] =&gt; file2.pdf
                                )

                        )

                )
        )
)
</code></pre>

<p>I want to convert it into:</p>

<pre><code>stdClass Object
(
    [Id] =&gt; 1
    [FAQCategoryId] =&gt; 1
    [TitleId] =&gt; 1
    [ContentId] =&gt; 2
    [Views] =&gt; 226
    [DateCreated] =&gt; 2011-10-31 11:17:44
    [DateModified] =&gt; 
    [Title] =&gt; My title..
    [Content] =&gt; My content..
    [AttachmentSet] =&gt; Array
        (
            [0] =&gt; stdClass Object
                (
                    [Id] =&gt; 1
                    [LanguageId] =&gt; 1
                    [FAQItemId] =&gt; 1
                    [Attachment] =&gt; file1.pdf
                )
            [1] =&gt; stdClass Object
                (
                    [Id] =&gt; 2
                    [LanguageId] =&gt; 1
                    [FAQItemId] =&gt; 1
                    [Attachment] =&gt; file2.pdf
                )
        )
)
</code></pre>
