帮助从 SOAP 响应中找出嵌套数组?
我正在使用 PHP 编写一个用于海洋潮汐的小网络应用程序。我在弄清楚如何访问返回的数组(PHP 将其转换为 stdObject)时遇到问题。
WSDL 文件位于:http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl
我的 PHP 代码是:
$wsdl = "http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl";
$tides = new soapclient($wsdl);
$tideParams = array(
'stationId' => '8454000',
'beginDate' => '20110821 00:00',
'endDate' => '20110821 23:59',
'datum' => '0',
'unit' => '0',
'timeZone' => '0'
);
$tideRet = $tides->getHighLowTidePredictions($tideParams);
var_dump($tideRet);
此转储返回:
object(stdClass)#2 (1) {
["HighLowValues"]=>
object(stdClass)#3 (1) {
["item"]=>
object(stdClass)#4 (2) {
["data"]=>
array(4) {
[0]=>
object(stdClass)#5 (3) {
["time"]=>
string(5) "00:35"
["pred"]=>
float(3.8)
["type"]=>
string(1) "H"
}
[1]=>
object(stdClass)#6 (3) {
["time"]=>
string(5) "05:45"
["pred"]=>
float(0.7)
["type"]=>
string(1) "L"
}
[2]=>
object(stdClass)#7 (3) {
["time"]=>
string(5) "12:49"
["pred"]=>
float(4.2)
["type"]=>
string(1) "H"
}
[3]=>
object(stdClass)#8 (3) {
["time"]=>
string(5) "18:32"
["pred"]=>
float(1.3)
["type"]=>
string(1) "L"
}
}
["date"]=>
string(10) "08/21/2011"
}
}
}
我不知道如何阅读这一点,我的谷歌搜索也没有多大帮助。任何帮助或指导表示赞赏。
I am writing a little web app for ocean tides using PHP. I am having problems figuring out how to access the array returned (which PHP converted to a stdObject).
The WSDL file is located at: http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl
My PHP code is:
$wsdl = "http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl/HighLowTidePred.wsdl";
$tides = new soapclient($wsdl);
$tideParams = array(
'stationId' => '8454000',
'beginDate' => '20110821 00:00',
'endDate' => '20110821 23:59',
'datum' => '0',
'unit' => '0',
'timeZone' => '0'
);
$tideRet = $tides->getHighLowTidePredictions($tideParams);
var_dump($tideRet);
This dump returns:
object(stdClass)#2 (1) {
["HighLowValues"]=>
object(stdClass)#3 (1) {
["item"]=>
object(stdClass)#4 (2) {
["data"]=>
array(4) {
[0]=>
object(stdClass)#5 (3) {
["time"]=>
string(5) "00:35"
["pred"]=>
float(3.8)
["type"]=>
string(1) "H"
}
[1]=>
object(stdClass)#6 (3) {
["time"]=>
string(5) "05:45"
["pred"]=>
float(0.7)
["type"]=>
string(1) "L"
}
[2]=>
object(stdClass)#7 (3) {
["time"]=>
string(5) "12:49"
["pred"]=>
float(4.2)
["type"]=>
string(1) "H"
}
[3]=>
object(stdClass)#8 (3) {
["time"]=>
string(5) "18:32"
["pred"]=>
float(1.3)
["type"]=>
string(1) "L"
}
}
["date"]=>
string(10) "08/21/2011"
}
}
}
I have no idea how to read into this and my googling hasn't helped much either. Any help or direction is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那是一个动态的 PHP 对象。所有引用的项目都是属性名称,因此要获取数据数组:
然后,如果您想获取特定项目的时间属性,例如,您可以寻址该数组索引并查找时间属性:
That is a dynamic PHP object. All of the quoted items are property names, so to get to the data array:
Then, if you want to get a particular item's time property, for example, you would address that array index and look up the time property: