我試圖從多維數組中提取數據,但每次嘗試寫入正確的路徑時都會收到此錯誤。由於路徑正確,我不知道有什麼問題。我可以從多維數組中提取特定數據
錯誤:
Notice: Undefined index: shipper in C:\xampp\htdocs\xml\dood.php on line 31
Notice: Undefined index: shipper in C:\xampp\htdocs\xml\dood.php on line 31
這是數組
Array
(
[Shp] => Array
(
[test] => Array
(
[shipper] => Array
(
[customer] => Array
(
[address] => Array
(
[ad1] => new road
[ad2] => newyork
[company] => none
[city] => JO
)
[newlang] =>
)
)
[reciver] => Array
(
[customer] => Array
(
[address] => Array
(
[ad1] => new road
[ad2] => newyork
[company] => none
[city] => JO
)
[newlang] =>
)
)
[test] => Array
(
[shipper] => Array
(
[customer] => Array
(
[address] => Array
(
[ad1] => new road
[ad2] => newyork
[company] => none
[city] => JO
)
[newlang] =>
)
)
[reciver] => Array
(
[customer] => Array
(
[address] => Array
(
[ad1] => new road
[ad2] => newyork
[AddrLn3] => newyork
[company] => none
[city] => JO
)
[newlang] =>
)
)
)
)
)
)
PHP代碼
$arr = $array; //Set this to your converted xml
$comps = $arr['Shp']['test'];
foreach($comps as $comp){
echo $comp['shipper']['customer']['address']['ad1'];
}
如何解決這個問題?
請幫我試過一切可能的東西
此的XML轉換爲數組 –