我有这个SimpleXMLElement对象。
[prices] => SimpleXMLElement Object
(
[price] => Array
(
[0] => SimpleXMLElement Object
(
[term] => 0.5
[price] => 35
[currency] => EUR
)
[1] => SimpleXMLElement Object
(
[term] => 1
[price] => 60
[currency] => EUR
)
[2] => SimpleXMLElement Object
(
[term] => 2
[price] => 50
[currency] => EUR
)
)
)
)
尝试创建$term[]
数组...
foreach($xmlData->prices->price as $term) {
$term[] = array(
'term' => (string)$term->term,
'price' => (string)$term->price,
'currency' => (string)$term->currency
);
}
但是得到警告:尚无法为以下字符串中的属性分配复杂类型:$term[] = array(
如何解决这个问题?
通过将$term[] = array(
更改为$terms[] = array(