1

我提出了一个 Soap 请求,它给了我一个充满 STDclasses 的数组。

我想要来自 Articlesummary 的结果,这样我就可以使用 ID 来查找正确的文章。

但是我现在尝试的所有代码都给我带来了 STDclass 和数组组合的问题

array(1) { 

["GetArticleSummariesResult"]=> object(stdClass)
#3 (2) { ["Errors"]=> object(stdClass)#4 (0) { } 

["ArticleSummaries"]=> object(stdClass)#5 (1) {

["ArticleSummary"]=> array(27) { 
[0]=> object(stdClass)#6 (4) { ["ID"]=> int(21557) ["Created"]=> string(19) "2010-05-06     15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) } 
[1]=> object(stdClass)#7 (4) { ["ID"]=> int(21638) ["Created"]=> string(19) "2010-05-06 15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) }
[2]=> object(stdClass)#8 (4) { ["ID"]=> int(21260) ["Created"]=> string(19) "2010-05-06 15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) } 
[3]=> object(stdClass)#9 (4) { ["ID"]=> int(26664) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } 
[4]=> object(stdClass)#10 (4) { ["ID"]=> int(22165) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } 
[5]=> object(stdClass)#11 (4) { ["ID"]=> int(24166) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-08-16 22:44:38" ["Active"]=> bool(true) } 
[6]=> object(stdClass)#12 (4) { ["ID"]=> int(26167) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } 
[7]=> object(stdClass)#13 (4) { ["ID"]=> int(26170) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2011-05-05 09:04:19" ["Active"]=> bool(true) } 
[8]=> object(stdClass)#14 (4) { ["ID"]=> int(29471) ["Created"]=> string(19) "2010-07-02 11:59:26" ["Modified"]=> string(19) "2010-07-02 11:59:26" ["Active"]=> bool(true) } 
[9]=> object(stdClass)#15 (4) { ["ID"]=> int(21157) ["Created"]=> string(19) "2011-03-04 09:34:11" ["Modified"]=> string(19) "2012-06-12 11:34:44" ["Active"]=> bool(true) } 
[10]=> object(stdClass)#16 (4) { ["ID"]=> int(272876) ["Created"]=> string(19) "2011-04-11 12:14:29" ["Modified"]=> string(19) "2012-09-04 14:25:07" ["Active"]=> bool(true) } 
[11]=> object(stdClass)#17 (4) { ["ID"]=> int(28328) ["Created"]=> string(19) "2011-05-03 12:25:07" ["Modified"]=> string(19) "2011-05-03 12:25:07" ["Active"]=> bool(true) } 
[12]=> object(stdClass)#18 (4) { ["ID"]=> int(226752) ["Created"]=> string(19) "2011-05-17 00:14:51" ["Modified"]=> string(19) "2011-05-25 10:48:22" ["Active"]=> bool(true) } 
[13]=> object(stdClass)#19 (4) { ["ID"]=> int(2231971) ["Created"]=> string(19) "2011-05-18 16:37:50" ["Modified"]=> string(19) "2011-05-18 16:40:12" ["Active"]=> bool(true) } 
[14]=> object(stdClass)#20 (4) { ["ID"]=> int(2970219) ["Created"]=> string(19) "2011-09-05 10:34:14" ["Modified"]=> string(19) "2011-09-05 10:34:14" ["Active"]=> bool(true) } 
[15]=> object(stdClass)#21 (4) { ["ID"]=> int(24178) ["Created"]=> string(19) "2011-11-18 18:54:16" ["Modified"]=> string(19) "2011-11-23 13:44:18" ["Active"]=> bool(true) } 
[16]=> object(stdClass)#22 (4) { ["ID"]=> int(3160171) ["Created"]=> string(19) "2012-01-18 10:55:09" ["Modified"]=> string(19) "2012-01-18 14:04:18" ["Active"]=> bool(true) } 
[17]=> object(stdClass)#23 (4) { ["ID"]=> int(394795) ["Created"]=> string(19) "2012-02-10 10:14:15" ["Modified"]=> string(19) "2012-02-10 10:14:16" ["Active"]=> bool(true) } 
[18]=> object(stdClass)#24 (4) { ["ID"]=> int(3236961) ["Created"]=> string(19) "2012-03-12 11:44:45" ["Modified"]=> string(19) "2012-03-12 13:34:37" ["Active"]=> bool(true) } 
[19]=> object(stdClass)#25 (4) { ["ID"]=> int(343578) ["Created"]=> string(19) "2012-06-07 15:24:07" ["Modified"]=> string(19) "2012-06-11 09:44:22" ["Active"]=> bool(true) } 
[20]=> object(stdClass)#26 (4) { ["ID"]=> int(3376400) ["Created"]=> string(19) "2012-07-03 13:55:40" ["Modified"]=> string(19) "2012-07-03 13:55:40" ["Active"]=> bool(true) } 
[21]=> object(stdClass)#27 (4) { ["ID"]=> int(33622) ["Created"]=> string(19) "2012-07-25 10:24:24" ["Modified"]=> string(19) "2012-07-25 10:24:24" ["Active"]=> bool(true) } 
[22]=> object(stdClass)#28 (4) { ["ID"]=> int(3404088) ["Created"]=> string(19) "2012-07-25 14:34:20" ["Modified"]=> string(19) "2012-07-25 14:34:20" ["Active"]=> bool(true) } 
[23]=> object(stdClass)#29 (4) { ["ID"]=> int(35046) ["Created"]=> string(19) "2012-07-26 15:14:13" ["Modified"]=> string(19) "2012-08-20 11:04:20" ["Active"]=> bool(true) } 
[24]=> object(stdClass)#30 (4) { ["ID"]=> int(37926) ["Created"]=> string(19) "2012-09-04 14:44:09" ["Modified"]=> string(19) "2012-09-04 14:44:09" ["Active"]=> bool(true) } 
[25]=> object(stdClass)#31 (4) { ["ID"]=> int(36657) ["Created"]=> string(19) "2012-09-17 16:14:53" ["Modified"]=> string(19) "2012-09-17 16:14:53" ["Active"]=> bool(true) } 
[26]=> object(stdClass)#32 (4) { ["ID"]=> int(32328) ["Created"]=> string(19) "2012-10-08 10:34:42" ["Modified"]=> string(19) "2012-10-08 10:44:33" ["Active"]=> bool(true) }

=} } } }

有人可以帮助我也请找到一种方法来获得结果。

<wsdl:operation name="GetArticleSummaries"><wsdl:documentation>Get publication summaries for publications that where last created/modified after the given date. 
                lastModified not specified will return all active publications.
                RequestedPropertyTypes (PropertyTypes) not specified will return all allowed types.
                Please use RequestedPropertyTypes instead of PropertyTypes, PropertyTypes will be removed in future versions.</wsdl:documentation><wsdl:input message="tns:GetPublicationSummariesSoapIn"/><wsdl:output message="tns:GetPublicationSummariesSoapOut"/>


<wsdl:message name="GetArticleSummariesSoapIn"><wsdl:part name="parameters" element="tns:GetPublicationSummaries"/></wsdl:message>


<s:element name="GetArticleSummaries"><s:complexType><s:sequence><s:element minOccurs="1" maxOccurs="1" name="LastModified" nillable="true" type="s:dateTime"/><s:element minOccurs="0" maxOccurs="unbounded" name="PropertyTypes" type="tns:PropertyType"/><s:element minOccurs="0" maxOccurs="1" name="RequestedPropertyTypes" type="tns:ArrayOfPropertyType"/></s:sequence></s:complexType></s:element>




$result = $client->GetArticleSummaries(array('ArticleId'));
$array = (array)$result;
var_dump($array);








object(stdClass)#2 (1) { ["GetPublicationSummariesResult"]=> object(stdClass)#3 (2) { ["Errors"]=> object(stdClass)#4 (0) { } ["PublicationSummaries"]=> object(stdClass)#5 (1) { ["PublicationSummary"]=> array(27) { [0]=> object(stdClass)#6 (4) { ["ID"]=> int(1441657) ["Created"]=> string(19) "2010-05-06 15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) } [1]=> object(stdClass)#7 (4) { ["ID"]=> int(1441658) ["Created"]=> string(19) "2010-05-06 15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) } [2]=> object(stdClass)#8 (4) { ["ID"]=> int(1441660) ["Created"]=> string(19) "2010-05-06 15:54:50" ["Modified"]=> string(19) "2010-05-25 19:54:09" ["Active"]=> bool(true) } [3]=> object(stdClass)#9 (4) { ["ID"]=> int(1456164) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } [4]=> object(stdClass)#10 (4) { ["ID"]=> int(1456165) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } [5]=> object(stdClass)#11 (4) { ["ID"]=> int(1456166) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-08-16 22:44:38" ["Active"]=> bool(true) } [6]=> object(stdClass)#12 (4) { ["ID"]=> int(1456167) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2010-05-25 19:54:07" ["Active"]=> bool(true) } [7]=> object(stdClass)#13 (4) { ["ID"]=> int(1456170) ["Created"]=> string(19) "2010-05-25 19:54:07" ["Modified"]=> string(19) "2011-05-05 09:04:19" ["Active"]=> bool(true) } [8]=> object(stdClass)#14 (4) { ["ID"]=> int(1489471) ["Created"]=> string(19) "2010-07-02 11:59:26" ["Modified"]=> string(19) "2010-07-02 11:59:26" ["Active"]=> bool(true) } [9]=> object(stdClass)#15 (4) { ["ID"]=> int(1721157) ["Created"]=> string(19) "2011-03-04 09:34:11" ["Modified"]=> string(19) "2012-06-12 11:34:44" ["Active"]=> bool(true) } [10]=> object(stdClass)#16 (4) { ["ID"]=> int(1772876) ["Created"]=> string(19) "2011-04-11 12:14:29" ["Modified"]=> string(19) "2012-09-04 14:25:07" ["Active"]=> bool(true) } [11]=> object(stdClass)#17 (4) { ["ID"]=> int(1808328) ["Created"]=> string(19) "2011-05-03 12:25:07" ["Modified"]=> string(19) "2011-05-03 12:25:07" ["Active"]=> bool(true) } [12]=> object(stdClass)#18 (4) { ["ID"]=> int(1826752) ["Created"]=> string(19) "2011-05-17 00:14:51" ["Modified"]=> string(19) "2011-05-25 10:48:22" ["Active"]=> bool(true) } [13]=> object(stdClass)#19 (4) { ["ID"]=> int(1830971) ["Created"]=> string(19) "2011-05-18 16:37:50" ["Modified"]=> string(19) "2011-05-18 16:40:12" ["Active"]=> bool(true) } [14]=> object(stdClass)#20 (4) { ["ID"]=> int(1970219) ["Created"]=> string(19) "2011-09-05 10:34:14" ["Modified"]=> string(19) "2011-09-05 10:34:14" ["Active"]=> bool(true) } [15]=> object(stdClass)#21 (4) { ["ID"]=> int(2084178) ["Created"]=> string(19) "2011-11-18 18:54:16" ["Modified"]=> string(19) "2011-11-23 13:44:18" ["Active"]=> bool(true) } [16]=> object(stdClass)#22 (4) { ["ID"]=> int(2160171) ["Created"]=> string(19) "2012-01-18 10:55:09" ["Modified"]=> string(19) "2012-01-18 14:04:18" ["Active"]=> bool(true) } [17]=> object(stdClass)#23 (4) { ["ID"]=> int(2194795) ["Created"]=> string(19) "2012-02-10 10:14:15" ["Modified"]=> string(19) "2012-02-10 10:14:16" ["Active"]=> bool(true) } [18]=> object(stdClass)#24 (4) { ["ID"]=> int(2236961) ["Created"]=> string(19) "2012-03-12 11:44:45" ["Modified"]=> string(19) "2012-03-12 13:34:37" ["Active"]=> bool(true) } [19]=> object(stdClass)#25 (4) { ["ID"]=> int(2343578) ["Created"]=> string(19) "2012-06-07 15:24:07" ["Modified"]=> string(19) "2012-06-11 09:44:22" ["Active"]=> bool(true) } [20]=> object(stdClass)#26 (4) { ["ID"]=> int(2376900) ["Created"]=> string(19) "2012-07-03 13:55:40" ["Modified"]=> string(19) "2012-07-03 13:55:40" ["Active"]=> bool(true) } [21]=> object(stdClass)#27 (4) { ["ID"]=> int(2403622) ["Created"]=> string(19) "2012-07-25 10:24:24" ["Modified"]=> string(19) "2012-07-25 10:24:24" ["Active"]=> bool(true) } [22]=> object(stdClass)#28 (4) { ["ID"]=> int(2404088) ["Created"]=> string(19) "2012-07-25 14:34:20" ["Modified"]=> string(19) "2012-07-25 14:34:20" ["Active"]=> bool(true) } [23]=> object(stdClass)#29 (4) { ["ID"]=> int(2405046) ["Created"]=> string(19) "2012-07-26 15:14:13" ["Modified"]=> string(19) "2012-08-20 11:04:20" ["Active"]=> bool(true) } [24]=> object(stdClass)#30 (4) { ["ID"]=> int(2447926) ["Created"]=> string(19) "2012-09-04 14:44:09" ["Modified"]=> string(19) "2012-09-04 14:44:09" ["Active"]=> bool(true) } [25]=> object(stdClass)#31 (4) { ["ID"]=> int(2466657) ["Created"]=> string(19) "2012-09-17 16:14:53" ["Modified"]=> string(19) "2012-09-17 16:14:53" ["Active"]=> bool(true) } [26]=> object(stdClass)#32 (4) { ["ID"]=> int(2502328) ["Created"]=> string(19) "2012-10-08 10:34:42" ["Modified"]=> string(19) "2012-10-08 10:44:33" ["Active"]=> bool(true) } } } } }
4

2 回答 2

0

您有一个关联的外部数组。它唯一的关键是GetArticleSummariesResult. ArticleSummaries是该数组中具有一个属性ArticleSummary的对象,它是一个对象数组。您要查找的值 ( ID) 是对象属性。

$outer_array: array, access with []
GetArticleSummariesResult: object stdClass
ArticleSummaries: object stdClass, access properties with ->
ArticleSummary: array with numeric indices, access with []
Objects in ArticleSummary array: object stdClass, access properties with ->

例子:

echo $outer_array['GetArticleSummariesResult']->ArticleSummaries->ArticleSummary[0]->ID;
// 21557
echo $outer_array['GetArticleSummariesResult']->ArticleSummaries->ArticleSummary[0]->Created;
// 2010-05-06     15:54:50
echo $outer_array['GetArticleSummariesResult']->ArticleSummaries->ArticleSummary[5]->ID;
// 24166

在一个循环中:

foreach ($outer_array['GetArticleSummariesResult']->ArticleSummaries->ArticleSummary as $summary) {
  // Print the id and created date
  echo $summary->ID . " " . $summary->Created . "\n";
}
于 2012-10-14T13:42:37.810 回答
0
    $result = array(); //your result

    foreach($result["GetArticleSummariesResult"]->ArticleSummaries->ArticleSummary as $sum)
    {

       //Search ID u want
       if($sum->ID == 009831)
          {
              //I got you.
          }
     }
于 2012-10-14T13:43:35.813 回答