从 SimpleXMLObject 到数组的递归转换

2021-12-31 00:00:00 casting php simplexml

我需要递归地将 PHP SimpleXMLObject 转换为数组.问题是每个子元素也是一个 PHP SimpleXMLElement.

I need to recursively cast a PHP SimpleXMLObject to an array. The problem is that each sub element is also a PHP SimpleXMLElement.

这可能吗?

推荐答案

json_decode(json_encode((array) simplexml_load_string($obj)), 1);

相关文章