我有一个从SOAP XML转换的复杂数组。我想循环遍历数组并获取ENV:BODY
部分并显示。有没有办法做到这一点 ?我试图预测,但由于索引名称不同,它有点复杂?有人会建议吗?谢谢
这是我的数组的输出
array (
'SOAPENV:ENVELOPE' =>
array (
'ENV:HEADER' =>
array (
'WSA:MESSAGEID' => 'urn:960ddd8d-87f0-11e5-a38e-00144ff9d767',
'WSA:REPLYTO' =>
array (
'WSA:ADDRESS' => 'http://www.w3.org/2005/08/addressing/anonymous',
'WSA:REFERENCEPARAMETERS' =>
array (
'INSTRA:TRACKING.ECID' => '52943d5a-ac40-4599-a378-d7c645ea11ca-000ab3ff',
'INSTRA:TRACKING.FLOWEVENTID' => '86675',
'INSTRA:TRACKING.FLOWID' => '71161',
'INSTRA:TRACKING.CORRELATIONFLOWID' => '0000L3nGuO6Fc5GLQyDCid1MBVWK0001VH',
),
),
'WSA:FAULTTO' =>
array (
'WSA:ADDRESS' => 'http://www.w3.org/2005/08/addressing/anonymous',
),
),
'ENV:BODY' =>
array (
'NS2:HELLOWORLDRESPONSE' =>
array (
'NS2:GREETING' => 'binnenbus Hallo SOA Qing ',
),
),
),
)
它是使用:
创建的printf("<pre> RESULT: %s</pre>\n",var_export($res,1));
答案 0 :(得分:1)
这里不需要循环。只需使用钥匙。
echo $res['SOAPENV:ENVELOPE']['ENV:BODY']['NS2:HELLOWORLDRESPONSE']['NS2:GREETING'];
如果你的意思是ENV:BODY中的键改变了,你可以像这样循环它们:
foreach ($res['SOAPENV:ENVELOPE']['ENV:BODY'] as $body_node)
{
foreach ($body_node as $value)
{
echo $value;
}
}