我有一个函数foo
,它返回一个具有以下结构的数组,我正在努力解决是否有更好的方法来构建我的 PHP,因为我不确定 foreach 中的索引,因为我想要每个ListingId
目标:
我想编写一个从外部 XML 文档foreach
中获取 XML 的循环<Name>
(尚未编写此部分,因为我需要将ListingID
from传递foo
到 url 以获取<Name>
)
PHP:
$test0 = $this->foo();
$test = $test0[0]['ListingId'];
结构:
Array ( [0] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532712629 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [1] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532712202 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [2] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532711566 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [3] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532710864 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [4] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532710271 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [5] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 532691526 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3400- ) ) [6] => Array ( [ListingId] => SimpleXMLElement Object ( [0] => 527496168 ) [ListingCategory] => SimpleXMLElement Object ( [0] => 0350-5748-3399- ) ) )