【发布时间】:2020-04-10 00:18:07
【问题描述】:
我正在从 api 获取 xml 数组,何时请在下面查看 我正在使用这个 foreach 循环。
foreach ($event->raidstatus as $status){
//i want to get name and cound i tried $status->name but failed
//and when i did print_r($status) then got array
echo '<pre>'; print_r($status); exit;
}
这是 print_r 结果
SimpleXMLElement Object
(
[status0] => SimpleXMLElement Object
(
[id] => 0
[name] => Bestätigt
[count] => 1
)
[status1] => SimpleXMLElement Object
(
[id] => 1
[name] => Angemeldet
[count] => 3
)
[status2] => SimpleXMLElement Object
(
[id] => 2
[name] => Abgemeldet
[count] => 4
)
[status3] => SimpleXMLElement Object
(
[id] => 3
[name] => Ersatzbank
[count] => 0
)
[required] => 40
)
请帮助我得到结果谢谢
【问题讨论】:
-
您能否显示 XML 看起来好像元素被称为
status0、status1等? -
对不起,我不明白你能帮我解决一下,给我与我的循环相关的答案吗?