从php中的数据集中获取数据

时间:2014-09-09 05:54:42

标签: php arrays

我是webservice的新人。我在.net webservice中使用了php application。它的工作,但我的结果是数据集形式。我怎样才能从中获取数据。我的结果是:

Array ( [WebmethodName] => 
    Array ( [schema] => 
       Array ( [element] => 
         Array ( [complexType] => 
            Array ( [choice] => 
              Array ( [element] => 
                Array ( [complexType] => 
                   Array ( [sequence] => 
                      Array ( [element] => 
                        Array ( [0] => Array ( [!name] => G101 [!minOccurs] => 0 ) 
                                [1] => Array ( [!name] => G102 [!minOccurs] => 0 ) 
                                [2] => Array ( [!name] => G103 [!minOccurs] => 0 ) 
                                [3] => Array ( [!name] => G104 [!minOccurs] => 0 )
                                [4] => Array ( [!name] => G105 [!minOccurs] => 0 ) 
                                [5] => Array ( [!name] => G106 [!minOccurs] => 0 ) 
                                [6] => Array ( [!name] => G107 [!minOccurs] => 0 ) 
                                [7] => Array ( [!name] => G108 [!minOccurs] => 0 ) 
                                [8] => Array ( [!name] => G109 [!minOccurs] => 0 ) 
                                [9] => Array ( [!name] => G110 [!minOccurs] => 0 ) 
                                [10] => Array ( [!name] => G111 [!minOccurs] => 0 ) 
                                [11] => Array ( [!name] => G112 [!minOccurs] => 0 ) 
                             ) 
                          ) 
                     ) 
               [!name] => Table 
            ) 
         [!minOccurs] => 0 [!maxOccurs] => unbounded 
         ) 
     ) 
     [!name] => NewDataSet [!msdata:IsDataSet] => true [!msdata:UseCurrentLocale] => true ) [!id] => NewDataSet ) [diffgram] => Array ( [NewDataSet] => Array ( [Table] => Array ( [G101] => 5053.png [G102] => 118 [G103] => .png [G108] => 5055 [G109] => 2014-09-05T14:50:59+05:30 [!diffgr:id] => Table1 [!msdata:rowOrder] => 0 ) ) ) ) )

我正在调用这个web服务。我可以找到this的结果。请帮助我。

<?php

    require_once('lib/nusoap.php');

    $wsdl = "url?wsdl";

    $mynamespace = "http://tempuri.org/";

    $theVariable = array('Id'=> '1022');

    $s = new SoapClient($wsdl,true);


    $result = $s->call('MethodName',array('parameters' =>  $theVariable));

    echo "<h1>Result:</h1>";

    echo "<pre>";


    print_r ($result);

        echo "</pre>";

?>

1 个答案:

答案 0 :(得分:0)

这是一个简单的数组,得到这样的数据......

require_once('lib/nusoap.php');
$wsdl        = "url?wsdl";
$mynamespace = "http://tempuri.org/";
$theVariable = array('Id'=> '1022');
$s           = new SoapClient($wsdl,true);
$result      = $s->call('MethodName',array('parameters' =>  $theVariable));

echo $result['WebmethodName']['schema']['element']['complexType']['choice']['element']['complexType']['sequence']['element'][0]['!name'];
//outputs eg G101

对于较短的来源,请尝试这样......

$users = $result['WebmethodName']['schema']['element']['complexType']['choice']['element']['complexType']['sequence']['element'];

foreach($users as $user){
    echo "Name: "      . $user['!name'] . "<br />";
    echo "MinOccurs: " . $user['!minOccurs'] . "<br /><br />";
}

会输出一些像

Name: G101
MinOccurs: 0

Name: G102
MinOccurs: 0

Name: G103
MinOccurs: 0

Name: G104
MinOccurs: 0

//and so on...
相关问题