array(2) { [0]=> object(Sim-6ren">
gpt4 book ai didi

php - 为什么 is_array() 返回 false?

转载 作者:可可西里 更新时间:2023-11-01 13:12:45 25 4
gpt4 key购买 nike

我有这个 SimpleXML 对象:

object(SimpleXMLElement)#176 (1) {
["record"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#39 (2) {
["f"]=>
array(2) {
[0]=>
string(13) "stuff"
[1]=>
string(1) "1"
}
}
[1]=>
object(SimpleXMLElement)#37 (2) {
["f"]=>
array(2) {
[0]=>
string(13) "more stuff"
[1]=>
string(3) "90"
}
}
}

为什么 is_array($object->record) 返回 false?它清楚地表明它是一个数组。为什么我无法使用 is_array 检测到它?

此外,我无法使用 (array) $object->record 将其转换为数组。我收到此错误:

Warning: It is not yet possible to assign complex types to properties

最佳答案

SimpleXML 节点是可以包含其他 SimpleXML 节点的对象。使用 iterator_to_array()。

关于php - 为什么 is_array() 返回 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4318090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com