0
我有一個函數foo
,它返回一個具有以下結構的數組,我正在努力解決的問題是有沒有更好的方法來構建我的PHP,因爲我不確定每個foreach中的索引, ListingId
Codeigniter身份不明索引
目標:
我想要寫一個foreach
循環,從外部XML文檔獲取XML <Name>
(沒有編寫本節還因爲我需要從foo
通過ListingID
進入網址得到<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-)))
你能澄清?我已經重讀了幾次,並不確定你在問什麼 –
這裏一樣。把一些預期的產出。可能是那麼清楚。 – itachi
@DavidNguyen我同意已經改變 –