序列化/反序列化封装的SimpleXML-Elements数组

时间:2018-03-06 21:30:44

标签: php laravel

我从API请求获得了一个封装的数组,如下所示:

Array
(
[1] => SimpleXMLElement Object
    (
        [id] => 1
        [link_rewrite] => fashion-supplier
        [name] => Fashion Supplier
        [active] => 1
        [date_add] => 2018-01-18 13:47:30
        [date_upd] => 2018-01-18 13:47:30
        [description] => SimpleXMLElement Object
            (
                [language] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 1
                                    )

                            )

                        [1] => SimpleXMLElement Object
                            (
                                [@attributes] => Array
                                    (
                                        [id] => 2
                                    )

                            )

                    )

            )

        [meta_title] => SimpleXMLElement Object
....

我希望将这些数据存储在Laravel-Cache中。由于里面的Simple-XML-Elements无法存储原始数据("序列化' SimpleXMLElement'不允许")。

有没有办法以可存储的形式转换这个复杂的array-simplexml-object-combination?问题是,我需要内部的XML-Attributes,这就是为什么我不能使用json_decode(json_encode($ array));

感谢您的帮助!

亚历

0 个答案:

没有答案