我试图从多数组获得价值,但那里有很多数组。我很迷惑。谁能帮我? 我需要从结果(在foreach中)获取GROUP_CODE和DESCRIPTION值,如下所示:
GROUP_CODE 01 DESCRIPTION BLACK
GROUP_CODE 02 DESCRIPTION WHITE
GROUP_CODE 04 DESCRIPTION RED
GROUP_CODE 07 DESCRIPTION BLUE
print_r结果:
Array
(
[GetGrupResult] => Array
(
[Result] => Array
(
[Error] =>
[Typ] => OK
)
[Set] => Array
(
[schema] => Array
(
[element] => Array
(
[complexType] => Array
(
[choice] => Array
(
[element] => Array
(
[complexType] => Array
(
[sequence] => Array
(
[element] => Array
(
[0] => Array
(
[simpleType] => Array
(
[restriction] => Array
(
[maxLength] => Array
(
[!value] => 2
)
[!base] => xs:string
)
)
[!name] => GROUP_CODE
)
[1] => Array
(
[simpleType] => Array
(
[restriction] => Array
(
[maxLength] => Array
(
[!value] => 50
)
[!base] => xs:string
)
)
[!name] => DESCRIPTION
[!minOccurs] => 0
)
)
)
)
[!name] => Table1
)
[!minOccurs] => 0
[!maxOccurs] => unbounded
)
)
[!name] => NewDataSet
[!msdata:IsDataSet] => true
[!msdata:UseCurrentLocale] => true
)
[!id] => NewDataSet
)
[diffgram] => Array
(
[NewDataSet] => Array
(
[Table1] => Array
(
[0] => Array
(
[GROUP_CODE] => 01
[DESCRIPTION] => BLACK
[!diffgr:id] => Table11
[!msdata:rowOrder] => 0
)
[1] => Array
(
[GROUP_CODE] => 02
[DESCRIPTION] => WHITE
[!diffgr:id] => Table12
[!msdata:rowOrder] => 1
)
[2] => Array
(
[GROUP_CODE] => 04
[DESCRIPTION] => RED
[!diffgr:id] => Table13
[!msdata:rowOrder] => 2
)
[3] => Array
(
[GROUP_CODE] => 07
[DESCRIPTION] => BLUE
[!diffgr:id] => Table14
[!msdata:rowOrder] => 3
)
)
)
)
)
)
)
var_dump结果
array(1) {
["GetGrupResult"]=>
array(2) {
["Result"]=>
array(2) {
["Error"]=>
NULL
["Typ"]=>
string(2) "OK"
}
["Set"]=>
array(2) {
["schema"]=>
array(2) {
["element"]=>
array(4) {
["complexType"]=>
array(1) {
["choice"]=>
array(3) {
["element"]=>
array(2) {
["complexType"]=>
array(1) {
["sequence"]=>
array(1) {
["element"]=>
array(2) {
[0]=>
array(2) {
["simpleType"]=>
array(1) {
["restriction"]=>
array(2) {
["maxLength"]=>
array(1) {
["!value"]=>
string(1) "2"
}
["!base"]=>
string(9) "xs:string"
}
}
["!name"]=>
string(10) "GROUP_CODE"
}
[1]=>
array(3) {
["simpleType"]=>
array(1) {
["restriction"]=>
array(2) {
["maxLength"]=>
array(1) {
["!value"]=>
string(2) "50"
}
["!base"]=>
string(9) "xs:string"
}
}
["!name"]=>
string(11) "DESCRIPTION"
["!minOccurs"]=>
string(1) "0"
}
}
}
}
["!name"]=>
string(6) "Table1"
}
["!minOccurs"]=>
string(1) "0"
["!maxOccurs"]=>
string(9) "unbounded"
}
}
["!name"]=>
string(10) "NewDataSet"
["!msdata:IsDataSet"]=>
string(4) "true"
["!msdata:UseCurrentLocale"]=>
string(4) "true"
}
["!id"]=>
string(10) "NewDataSet"
}
["diffgram"]=>
array(1) {
["NewDataSet"]=>
array(1) {
["Table1"]=>
array(4) {
[0]=>
array(4) {
["GROUP_CODE"]=>
string(2) "01"
["DESCRIPTION"]=>
string(3) "BLACK"
["!diffgr:id"]=>
string(7) "Table11"
["!msdata:rowOrder"]=>
string(1) "0"
}
[1]=>
array(4) {
["GROUP_CODE"]=>
string(2) "02"
["DESCRIPTION"]=>
string(6) "WHITE"
["!diffgr:id"]=>
string(7) "Table12"
["!msdata:rowOrder"]=>
string(1) "1"
}
[2]=>
array(4) {
["GROUP_CODE"]=>
string(2) "04"
["DESCRIPTION"]=>
string(15) "RED"
["!diffgr:id"]=>
string(7) "Table13"
["!msdata:rowOrder"]=>
string(1) "2"
}
[3]=>
array(4) {
["GROUP_CODE"]=>
string(2) "07"
["DESCRIPTION"]=>
string(3) "BLUE"
["!diffgr:id"]=>
string(7) "Table14"
["!msdata:rowOrder"]=>
string(1) "3"
}
}
}
}
}
}
}
答案 0 :(得分:0)
试试这个......我认为这是正确的。这就是阵列!:
<?php
$data = $array['GetGrupResult']['Set']['diffgram']['NewDataSet']['Table1'];
foreach($data as $key => $value) {
print_r($value);
} ?>